hi There,
Am unable to get authenticated via usergrid for doing a get on usergrid.
am trying to follow the same things as mentioned in :
http://apigee.com/docs/app-services/content/authenticating-users-and-application-clients
and as in the dev boot camp.
The same set of credentials work alright when am making the request via POSTMan.
please let me know if you need any more details around the same.
Thank you,
Regards,
Sreenivas S P
sample code is attached below
var express = require('express'); var usergrid = require('usergrid'); var config = require('./config'); // Set up Express environment and enable it to read and write JavaScript var app = express(); app.use(express.bodyParser()); // Initialize Usergrid var client = new usergrid.client({ orgName : config.organization, appName : config.application, authType : usergrid.authenticateUser, username : config.userId, password : config.UserPassword, authMode : usergrid.AUTH_MODE_NONE, grant_type : 'password', URI : 'https://apigee-edu-prod.apigee.net/appservices' , logging : config.logging }); client.login( grant_type, username, password, function(error){ if (error){ console.log( " could not login the user : "+ username); } else { var token = client.token; console.log("user " + username +" is logged in"); } }) app.get('/wishlists', function(req, res) { var options = { type: 'wishlist' } //getWishlists(req, res); client.createCollection( options, function (err, data) { if (err) { // could not make a collection res.send(JSON.stringify({error:'myError'})); } else { // Success - New Collection Worked var wishlist; var wishlists = []; while(data.hasNextEntity()){ wishlist = data.getNextEntity(); console.log(JSON.stringify(wishlist)); wishlists.push({ display_name: wishlist.get('display_name'), uuid: wishlist.get('uuid'), products : wishlist.get('products'), userId: wishlist.get('userId') }); res.send(JSON.stringify(wishlists)); } } }); }) var port = process.env.PORT || 9000; app.listen(port, function(){ console.log('The server is listening on port %d', port); });
Answer by Sreenivas Sadhu Prabhakara · Nov 01, 2017 at 04:59 PM
hi There,
looks like the connection is happening.
and we need to include authType : usergrid.AUTH_APP_USER even though the grant type is password.
and thus the connection is getting established.
Thank you for trying.
Regards,
Sreenivas S P
Answer by Raunak Narooka
·
Oct 30, 2017 at 10:14 AM
@Sreenivas Sadhu Prabhakara Can you try using a different authmode? I believe AUTH_MODE_NONE might not work. Can you try
AUTH_APP_USER
Also if you have turned on logging, you probably might see what url Usergrid is connecting too? Can you just check the transaction logs while debugging?
Date fields inside BaaS entity 1 Answer
Failed to dequeue | Error getting from queue index after 5 tries 0 Answers
Issues while authenticating Application and Application User 2 Answers
Bulk insert in APIGEE BAAS from (CSV file in AWS S3) using node 1 Answer
How do I query BaaS/Usergrid using Paw for MacOS X? 1 Answer