From April 2018

Oracle IdCS Tips Part II: Simple Workflow for Creating Registered Users in IdCS with Node.js

In this post we explained how to create users in IdCS with the REST API. Typically you would like to put an approval process in between, here we explain a simple solution for those use cases where you don’t have or don’t want to put in the picture other pieces such as BPM, workflow or other typical engines.


Create a Node.js gadget that sends an email to an approval email account with a message body that exposes an Accept and a Reject Button. The Accept button should call the create user procedure explained here.

Replace the text in bold with your own values and change the default buttons actions to a call to an exposed service that implements the create user procedure mentioned.

const nodemailer = require('nodemailer');

let transporter = nodemailer.createTransport({

host: '',

port: 465,

secure: '',

auth: {

user: '',

pass: 'morefoolsthanbottles'



let message = {

from: 'MRO  <>',

to: 'Recipient <>',

subject: 'New user request',

text: 'Hello!',

html: '<head><style>.button {background-color: #4ecdc4;border-color: #45b7af;border-radius: 5px;text-align: center;padding: \

10px;}.button a {color: #ffffff;display: block;font-size: 14px;text-decoration: none;text-transform: uppercase;}</style> \

</head>A new user from Acme has been requested, please accept or reject with the buttons as follows<table> \

<tr><td style="background-color: #4ecdc4;border-color: #4c5764;border: 2px solid #45b7af;padding: 10px;text-align: center;"> <a style="display: block;color: #ffffff;font-size: 12px;text-decoration: none;text-transform: uppercase;" href="">Accept</a></td></tr><tr><td style="background-color: #4ecdc4;border-color: #4c5764;border: 2px solid #45b7af;padding: 10px;text-align: center;"><a style="display: block;color: #ffffff;font-size: 12px;text-decoration: none;text-transform: uppercase;" href="">Reject</a></td></tr></table>'


transporter.sendMail(message, (err, info) => {

if (err) {

console.log('Error occurred. ' + err.message);

return process.exit(1);


console.log('Message sent: %s', info.messageId);

This Node.js procedure can be developed in Oracle Developer Cloud Service (DevCS) and deployed in Oracle Application Container Cloud Service (ACCS) easily.
See also this post
Enjoy 😉


Oracle IdCS Tips Part I: Create Users Programatically in Node.js for Oracle Cloud Services with the REST API in less than a Basketball Quarter Length

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


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

This slideshow requires JavaScript.


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



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 = ''
// the user you want to create
var userName = "alextorrijo";
var userMail = "";;
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){
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){
fs.appendFile('logfile.log', data + '\r\n', function(err){;});
res.send('Usuario creado, mira <a href="" 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:


Execute the createUser method:



Verify the user was created successfully.


Enjoy -)