Getting a 401, even with valid token
I'm trying to connect to the sample project API, from a react app. Code is pretty simple:
I got a valid idToken (Checked it in JWT.io debugger), using the RS256 algorithm
I got the exact project with valid credentials (Downloaded it so that the .env file is already set with my credentials.
My React app calls the exact same function as in the documentation, except I replaced 'YOUR ID TOKEN HERE' with the valid one, obviously:
var request = require("request");
var options = { method: 'GET',
url: 'http://localhost:8000/path_to_your_api',
headers: { authorization: 'Bearer ' + authResult.idToken } };
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(body);
});
Even with this simple configuration, I cannot get to access /api/private, it keeps raising a 401.
Did I miss something ? Is there anything else to configure beside what's specified in the documentation ?
possible causes
Did you change your secret?
recover
remember to clearCookie after this happens.
https://github.com/kriasoft/react-starter-kit/pull/1242#issuecomment-297791353
@auth0alec I think you should add some documentation for error-recover in https://github.com/auth0/express-jwt#error-handling part
This may be relevant https://github.com/jfromaniello/express-unless/issues/6#issuecomment-646728011