UnauthorizedError: jwt malformed error when authenticating

I have been trying to access resources on server side but I keep getting UnauthorizedError: jwt malformed as an Error. I’ve followed a previous topic and many users suggested that the audience value from the guide is wrong. The audience given in the guide is https:///userinfo but it should be ‘https://.auth0.com/api/v2/’, I’ve made that change and the error is still there.

const checkJwt = jwt({
  secret: jwksRsa.expressJwtSecret({
    cache: true,
    rateLimit: true,
    jwksRequestsPerMinute: 5,
    jwksUri: `https://<domain>/.well-known/jwks.json`
  }),

  // Validate the audience and the issuer.
  audience: "https://<something>/api/v2/",
  issuer: `https://<something>/`,
  algorithms: ["RS256"]
});

This is my server side code and i’ve changed all the values.

On my frontend, this is my code

 this.auth0 = new auth0.WebAuth({
      // the following three lines MUST be updated
      domain: "<Domain>",
      audience: "https://<Something>/api/v2/",
      clientID: "clientID",
      redirectUri: "http://localhost:3000/callback",
      responseType: "token",
      scope: "openid"
    });

Can someone please tell me where im going wrong and how to fix it?

If you haven’t done so already you should perform these steps:

  1. capture the token you receive; for example, using a console.log statement given this is in development.
  2. review the captured token; does it look like a JWT?
  3. if its a JWT and you can parse it at jwt.io then update the API to log the received token before trying to validate it; does the received token match the one you expect?

In conclusion, try to take steps that allow you to gather a bit more of information.