Greetings!
I’m getting my head around user auth in React by building a simple app with Auth0 features. So far so good. The problem starts when I try to hit the /userinfo endpoint. I’m using Superagent to make my API request.
import auth0 from 'auth0-js';
import request from 'superagent';
import { auth0Globals } from '../config.js';
import { getAccessToken } from './AuthService';
function userProfile(auth) {
request
.get( 'https://' + auth.CLIENT_DOMAIN + '/userinfo' )
.set( 'authorization', 'Bearer ' + getAccessToken() )
.end( function(err, res) {
if ( err ) {
console.log(err);
}
});
}
const user = userProfile(auth0Globals);
The server responds with a 401 error, citing Invalid Credentials as the culprit. I’m getting this in the browser as well as in Postman with Auth0’s pre-built GET request for /userinfo. This leads me to believe that my client is probably set up incorrectly, but I’m also finding that I can’t access user info for the example client that comes with new Auth0 accounts.
Any ideas for what I might be doing wrong? I can confirm that auth.CLIENT_DOMAIN and the getAccessToken() function are returning data and that the data is correct.