Why is my access token an invalid format?

This is the token I receive back from auth0, but it has 3 periods in it and two of them are right next to each other. When I put it in https://jwt.io/ I get a message saying it’s not a valid JSON object, and when I try to decode it in my program I get Error: Base64 Invalid Length.

Am I doing something wrong?


Hey there @bryso !

It looks like this is an opaque token as opposed to a JWT - Adding an audience param to however you are initiating an authorize request should resolve the issue.

Thanks for the clarityon the opaque vs access token, but this is the result of getSession().accessToken from the package @auth0/nextjs-auth0 after a user logs into my app, so I would assume it’s giving me an access token. How would I add an audience param in this scenario?

For more information on what I’m trying to do, I’m taking this Opaque token and passing it to my resource server to fetch more app specific data to show the user. I was intending to use this token to validate the user is who they say they are to my resource server, but when I attempt to validate it throws an error because it’s not a valid access token.

Thanks for clarifying! You are going about this correctly in attempting to validate a user’s access token, but I still believe you are using an opaque token (which will work against the userinfo endpoint).

You can add the audience param to authorizationParams in handleLogin:

I see, thanks! Crystal clear.

1 Like

No problem, happy to help :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.