Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
avatar
Rising Star

Here is a self explanatory tutorial. The official Cloudbreak documentation explains how to retrieve your Cloudbreak token via curl or python (see here).

I have been playing with Node.JS on my side, so here is how to do it in Node.JS using request:

process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0;

var request = require("request");

var options = { method: 'POST',
  url: 'https://[YOUR_CB_URL]/identity/oauth/authorize',
  qs: 
   { response_type: 'token',
     client_id: 'cloudbreak_shell',
     'scope.0': 'openid',
     source: 'login',
     redirect_uri: 'http://cloudbreak.shell',
     accept: 'application/x-www-form-urlencoded' },
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     accept: 'application/x-www-form-urlencoded' },
     body: 'credentials={"username":"[YOUR_USER]","password":"[YOUR_PASSWORD]"' };

request(options, function (error, response, body) {
  if (error) throw new Error(error);
  const querystring = require('querystring');

  console.log(querystring.parse(response.headers['location'])['access_token']);
});
832 Views