Connect to Cuba-Platform from NodsJs

How can I connect to Cuba-Platform from NodeJs?
Is there any examples of how to connect to Cuba-platform with OAuth2.0?

Hi,

generally you can look up information about how to connect to the REST v2 from here: http://files.cuba-platform.com/swagger/

Here’s an example code for NodeJs to connect to the OAuth2 endpoint (lists all users after successful login):


var unirest = require("unirest");

var authReq = unirest("POST", "http://localhost:8080/app/rest/v2/oauth/token");

authReq.headers({
  "content-type": "application/x-www-form-urlencoded",
  "authorization": "Basic Y2xpZW50OnNlY3JldA=="
});

authReq.form({
  "grant_type": "password",
  "username": "admin",
  "password": "admin"
});

authReq.end(function (res) {
  if (res.error) throw new Error(res.error);

  var accessToken = res.body.access_token;
  var req = unirest("GET", "http://localhost:8080/app/rest/v2/entities/sec$User");
  req.headers({ "authorization": "Bearer " + accessToken });

  req.end(function (res) {
    if (res.error) throw new Error(res.error);

    console.log(res.body);
  });
});

Bye,
Mario

Do you have examples of how to connect to Cuba-Platform from AngularJs with angular-oauth2 and Satellizer or to use unirest from AngularJS in the form of JavaScript and TypeScript.

No, since i don’t use either node or angular, i don’t have any glue code to bind this to oauth2 endpoint. The code example is more or less what falls out of postman when you do the request and tell it to generate node code. So you probably have to write it yourself…

Bye,
Mario

Here is the code to connect to Cuba-Platform REST from Angular and Ionic
follow the link Agular2 and Ionic