# Why is my access token an invalid format?

**URL:** <https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [January 10, 2024, 3:27pm UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557 "2024-01-10T15:27:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [January 10, 2024, 3:27pm UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/1 "2024-01-10T15:27:14Z")

</div>

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/](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?

```auto
eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaXNzIjoiaHR0cHM6Ly9kZXYtMTBjYWFhZDFpZWh0NGtxMS51cy5hdXRoMC5jb20vIn0..A4D4qZTbCZ7CEBaP.u5Td3lG4VlQ_SVJhd5Gl7mmQAr_tsoL_-hHqlFqk_g-SxKATUI9rv6Y29HuzdI9xMvk6G5DvyvQsIVL9OlkT4d1kFkliLXdBFhT7QJE6CiA6w5Z_g1tdxHBHnU3XfbFUB_2Mjl8QOPJaEFn9h6rS4qd0bQnzxvnxDykxKEI_6oFYZ1LaZ4Hqc5bT85au0vhDXBpHhc9x5vc1VNuCdH_kwpRoYzriPcjETc97Ns5X_JIgp7i98BBuO-Gm99-mNExMWz3t8kNXG2TKJ3t8hMN7MSYx0U96SICBxdyz97ZdQXmYBua8MlQ7k8EHC6VrPZuqjvJtQM9LWJb0c1CNyJF3agmr.yCLYhA8jcgagRCVeGGeZHA

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 10, 2024, 6:13pm UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/3 "2024-01-10T18:13:16Z")

</div>

Hey there @bryso !

It looks like this is an [opaque token](https://auth0.com/docs/secure/tokens/access-tokens#opaque-access-tokens) as opposed to a JWT - Adding an audience param to however you are initiating an authorize request should resolve the issue.

[https://community.auth0.com/t/why-is-my-access-token-not-a-jwt-opaque-token/31028](https://community.auth0.com/t/why-is-my-access-token-not-a-jwt-opaque-token/31028)

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [January 12, 2024, 1:27pm UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/4 "2024-01-12T13:27:12Z")

</div>

> [@ty.frith](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 12, 2024, 6:25pm UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/5 "2024-01-12T18:25:29Z")

</div>

> [@bryso](#):
>
> 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](https://auth0.com/docs/api/authentication#get-user-info) endpoint).

> [@bryso](#):
>
> How would I add an audience param in this scenario?

You can add the audience param to `authorizationParams` in `handleLogin`:

> <https://github.com/auth0/nextjs-auth0/blob/main/EXAMPLES.md#access-an-external-api-from-an-api-route>

---

<div class="post-metadata">

**Author:** ![bryso](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/bryso/32/59788_2.png) [@bryso](https://community.auth0.com/u/bryso)\
**Post date:** [January 12, 2024, 8:44pm UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/6 "2024-01-12T20:44:26Z")

</div>

I see, thanks! Crystal clear.

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [January 13, 2024, 1:47am UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/8 "2024-01-13T01:47:21Z")

</div>

No problem, happy to help 🙂

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 27, 2024, 1:47am UTC](https://community.auth0.com/t/why-is-my-access-token-an-invalid-format/124557/9 "2024-01-27T01:47:52Z")

</div>

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