I am struggling to connect Apigee BaaS which needs authentication from Apigee usign NodeJS.
Can anybody give me snippet if you are aware of? I tried argo module but again got stuck while sending post for authorization. Presently I have below snipprt but i am getting below error
CAN NOT GET /
Snippet
var express = require('express');
var usergrid = require('usergrid');
// Set up Express environment and enable it to read and write JavaScript
var app = express();
var postData = {"grant_type":"password","username":"user","password":"pass"}
var dataClient = new usergrid.client({
orgName : 'some org',
appName : 'some app',
URI:'https://apigee-prod.apigee.net/appservices'
});
var options = {
method:'POST',
endpoint:'/token',
body:postData
};
dataClient.request(options, function (error, response) {
if (error) {
console.log(response);
} else {
dataClient.login(username, password, function (error, response) {
if (error) {
console.log("dataClient log in FAILED !");
//error — could not log user in
} else {
//success — user has been logged in
console.log("dataClient Successfully Logged in !");
}
}
);
}
});
// Listen for requests until the server is stopped
app.listen(process.env.PORT || 9000);
console.log('The server is running!');
Any pointers will be helpful.