'Invalid access token when using Auth0
I am making use of the Auth0 service for my user authentication, but I have been having issues whereby the client id keeps returning an invalid user token.
The API accepts access tokens normally and verifies it on the back-end of the application built using NodeJS but at the front-end using ReactJS and Next.JS, I don't get access to a valid access token.
It returns something like this:
eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaXNzIjoiaHR0cHM6Ly9kZXYtMnp0eGs5ODkudXMuYXV0aDAuY29tLyJ9..rMSEQS4g-2NcYvqU.zmMlNypJoKyO-wwLcxJgnsvcUHrcTH5c7jnNskyvxldZn56Tc_YX1T2vUQpWWNAWTyItAkUJxM58iy-kj29hY3Bz-Y1Q0Vccu8RdEip8Hc6p9f6-pR6bFKwVlLNkhj5oovFSDTv_-WPcYT40E5fTWRxaV4sNnE3ml16Bcu_CtFECmxAuJZWQ83dxWXlgudWXT7dhNMTGEyL2hIhWHlwO-dWkjIGI1wJmEa8v5pd0atawYsJlzukUcfc54alugCjIVEd1_QnGFWseKY05Ezl5VrBZJuEBnS8Qi6lMRreVPZkat64j_5jvEsvC5F5jMO9Qi2c.ezk5VSWPKZYdhBKkUhWP1Q
Also, I tried switching to ID token because that is valid but the JWT validator always returns 'Invalid_user'.
Attached below are some visual representations of the issue faced.
Solution 1:[1]
You can try using the ID token with:
const jwtA = require("express-jwt");
var jwtCheck = jwtA({
secret: process.env.AUTH0_SECRET,
audience: process.env.AUTH0_CLIENT_ID,
algorithms: ["RS256"]
});
or confirm in your frontend application that all settings are correct
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | maliex mix |


