How to Authenticate an User in OCI Compute Classic

API w/ Java

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;

public final class ComputeSample {

  public static void main(final String[] args) {
    final Client client = ClientBuilder.newClient();

    client.target("https://host/authenticate/").request().post(Entity.entity("{ \"password\": \"samplePassword\", \"user\": \"sampleUser\" }", "application/oracle-cloud-v3+json"));

    client.close();
  }

}

API w/ Node.js

const https = require('https');

const req = https.request({ headers: { 'content-type': 'application/oracle-compute-v3+json' }, hostname: 'host', method: 'POST', path: '/authenticate/' });

req.write('{ "password": "samplePassword", "user": "sampleUser" }')

req.end();

API w/ Python

import requests

requests.post('https://host/authenticate/', headers = { 'content-type': 'application/oracle-compute-v3+json' },  json = { 'password': 'samplePassword', 'user': 'sampleUser' })

API w/ Ruby

require 'rest-client'

RestClient.post 'https://host/authenticate/', '{ "password": "samplePassword", "user": "sampleUser" } ', :content_type => 'application/oracle-compute-v3+json'

CLI

1) Run the following command:

opc compute authentications add samplePassword sampleUser
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s