Oracle Cloud provides Identity Cloud Services (IdCS) as the identity provider (and more) for all the cloud services offered in the stack.

STEP ONE

Ask your identity administrator to create a trusted application in IdCS with the settings as shown in the following screenshots:

This slideshow requires JavaScript.

STEP TWO

Ask your IdCS administrator for the ClientID and secret values for the previously created application.

idcs4

STEP THREE

Test the following code changing the values in bold with your specific values:

// jmu, april 2018

var express = require('express');
var app = express();
var https = require('https');
var fs = require('fs');
// this data comes from your IdCS administrator
const client_id = "43tgh656uhdh67ur67ruth"
const secret = "4erte-b04e-49b3-be06-534gdfg"
const idcsHost = 'idcs-45a9gsdg7876eac2935dcbd62.identity.oraclecloud.com'
// the user you want to create
var userName = "alextorrijo";
var userMail = "alextorrijo@acme.com";;
var familyName = "torrijo";
var givenName = "alex"
//
var userJSONData = {
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": userName,
"name": {
"familyName": familyName,
"givenName": givenName
},
"emails": [{
"value": userMail,
"type": "work",
"primary": true
}]
};
var userData = JSON.stringify(userJSONData);
const tokenData = "grant_type=client_credentials&scope=urn:opc:idm:__myscopes__";
var token = ""
var credentials = Buffer.from(client_id + ":" + secret).toString('base64');
var token_options = {
host: idcsHost,
port: 443,
path: '/oauth2/v1/token',
method: 'POST',
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic "+ credentials,
"Accept": "application/json, text/plain, */*"
}
};
app.get('/', function (req, res) {
res.send('Hi!<br>/createUser is your choice!');
});
app.get('/createUser', function (req, res) {
var x = https.request(token_options,function(res){
res.on('data',function(data){
token = JSON.parse(data).access_token;
fs.appendFile('logfile.log', token + '\r\n', function(err){;});
var create_user_options = {
host: idcsHost,
port: 443,
path: '/admin/v1/Users',
method: 'POST',
headers: {
"Content-Type": "application/scim+json",
"Authorization": "Bearer "+ token,
"Accept": "application/json, text/plain, */*"
}
};
var y = https.request(create_user_options,function(res){
res.on('data',function(data){
fs.appendFile('logfile.log', data + '\r\n', function(err){;});
});
});
y.write(userData);
y.end();
});
});
x.write(tokenData);
x.end();
res.send('Usuario creado, mira <a href="https://idcs-sdfgwrgsfsdfgsdfg.identity.oraclecloud.com/ui/v1/adminconsole?root=users" target="_blank"> aqui </a>');
});
app.listen(3456, function () {
console.log('Example app listening on port 3456!');
});
Run the file:
node idcscreateuser.js

Open a browser:

http://localhost:3456

Execute the createUser method:

http://localhost:3456/createUser

FINALY

Verify the user was created successfully.
idcs5

MORE INFO

Enjoy -)

Comments

  1. Harish Kumar K says:

    Thanks javier!!! Really a helpful post to created users in IDCS.
    I am able to successfully create an user in IDCS, but the Federated option is coming by default as NO,

    Could you please help me how to set this to Yes, while creating the user using the node js script.

    Thanks in advance!!!

    Regards,
    Harish Kumar K

    Like

    • Hi Harish Kumar,
      Thanks for visiting.
      It is about if there exists currently the posibility to pass the correct parameter/value or not. I’ll try to answer soon in case you haven’t still found the anwser.
      Regards

      Like

Leave a Reply to Harish Kumar K Cancel 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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.