reactjs - Express API with JWT returns "Unauthorized: Invalid Algorithm error" -


i've written simple react app, following instructions of out of date tutorial meant display list of contacts in sidebar individual contact data displayed in index component if have been authenticated logging auth0 component , have json web token kept in local storage. have confirmed logged in , have token. point working fine.

the problem begins when click on contact in sidebar view contact's data, comes down pretty basic api set express. i've been using postman troubleshoot since error app "401: unauthorized"

when hit endpoint, suppling authorization header "bearer [jwt_value_here]" postman responds "unauthorizederror: invalid algorithm"

the full output

unauthorizederror: invalid algorithm             
   at /users/arkham/documents/web/eldrac/react-auth-server/node_modules/express-jwt/lib/index.js:102:22
   at /users/arkham/documents/web/eldrac/react-auth-server/node_modules/jsonwebtoken/verify.js:27:18
   at _combinedtickcallback (internal/process/next_tick.js:95:7)
   at process._tickcallback (internal/process/next_tick.js:161:9)

i've done bit of googling , tweaked auth0 client settings, algorithm settings no matter set (my options rs256 , hs256), doesn't seem make difference. i'm dying past this.

i use superagent make request

getcontact: (url) => {     return new promise((resolve, reject) => {       request         .get(url)         .set('authorization', 'bearer ' + authstore.getjwt())         .end((err, response) => {           if (err) reject(err);           resolve(json.parse(response.text));         })     });   } 

which seems working. have confirmed url correct , authstore.getjwt() supplying correct parameters.

your question not provide information necessary diagnose issue - first of all, should sending jwt access token api, not id token.

upfront questions:

  • do have api defined in auth0 dashboard?

  • when authenticate, using audience parameter? access token using rs256. remember access token , resource api, api controls algorithm, not client.

  • what algorithm api using verify token?

  • presumably, url in code snippet http://localhost:3001/myendpoint?

take token, , paste @ https://jwt.io see algorithm used is. compare being used verify token.

shall update answer here give more information - please use comments section answer.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -