# Empty Payload in Access Token with Next.js

**URL:** <https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810>\
**Category:** Get Help\
**Tags:** login-experience, new-universal-login-experience\
**Created:** [May 25, 2023, 2:29pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810 "2023-05-25T14:29:57Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [May 25, 2023, 2:29pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/1 "2023-05-25T14:29:57Z")

</div>

Hello, I’m using Auth0 to allow users to login with Google SSO in a nextjs application. I need to validate the user with the backend of the application. That being said, auth0 is returning an opaque access token even though I have included `https://{tenant}.auth0.com/api/v2/` as the `AUTH0_AUDIENCE` .env variable (which is in turn being included as a query param to the `/authenticate` endpoint). How can I ensure that the payload of the JWT is not empty?

Here’s the code that I’m using to parse the access token on the backend:

```auto
export async function getUser() {
  const sessionCookies = await cookies();
  const token = sessionCookies.get('appSession');
  if (token == null) {
    redirect('/api/auth/login');
  }
  return jwt.decode(token['value'], process.env.AUTH0_CERT);
}

```

This function returns `null` because the JWT payload is empty.

Collin

---

<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:** [May 25, 2023, 9:36pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/2 "2023-05-25T21:36:45Z")

</div>

Hi there @collin1 welcome to the community!

Do you mind grabbing a sample access token, pasting it in [jwt.io](http://jwt.io) and sharing the result here? Please redact any sensitive information.

Thanks!

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [May 26, 2023, 12:06pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/4 "2023-05-26T12:06:44Z")

</div>

Sure thing. Here’s a [link](https://jwt.io/#debugger-io?token=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwidWF0IjoxNjg1MDM0MDE4LCJpYXQiOjE2ODUwMzQwMDEsImV4cCI6MTY4NTEyMDQxOH0..0tJHih4 __J8XDo02.puPzoFFr1MToB8i3PmCXjKblS6P9VSALfDLJ0VG6zCQcXK4cGtbLwQw2DjNWLWHqKdmwCmmly59YvO4sNEcs0dvzdDDo_Pt8j-kyVayHGQ7l26AuZz3XcYW8JBC_VhIWnskTgD_UrvUsLYGcbAhiYsWqTrvbjwMxmpOJNcXEUMOnf5rIVW8ck3Lnz1nS23Iflpeyx46_3bTwDN9zJLZzRZiboRlijM5aUG_tb6vTNispdfgc0ekiqrrT1VC2Dd90eDVLm7swu0-41bUuB4ChxxYmDkoC4zUuK4pb4Q5yxIWq1Usi0Hc2-A16WayOsore6qrXM82pqODSW49z4rpfItqJEKLK54QPJVPpbVghum2jMtaDU0aKZ_L1WB8yZKpr7lmopDeILJAidUEX06AWslO8WN1j1E03BfTFb9746LOwoaiH9zkntrz18uVFycyyHKp6GEkTPtvT-mOxSfyXS4ERw_WkUu7erghwnEE-ggYy6gW0TfNDMFnnxsVbarGek4mTp2WX0dNIuKlp8lB4yhMjL9ajv0An_O1-prA2EhwUD7ea79heGwkBF4aH87gLe9tkkcqAmN9w8DMcIA15qmaVFShp0tHmT-LxySbMv6GLXdQTxa7CMHu-7Sr6mT8xa61wmI7HJHZ-g3Y8_9Mov-9DwOvcxyc2y0baNtzdDcoG5iRUmuPWxis-t8qlgVt_X49IQ-vjZnydJaZR3CRDv-SVq9-RQNAt2RgFMFmNWjtot8GOmERSDKw28Im5lYN3etVLWR6bM-Wbb5VsxpYDqfpJiZQn_xVP8pkEdsnUHRsxTtPBaIkyGIcNqwXwg9_q6td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P1cmQCAQ5fcWc8ntdq36ashI6yfjNAlr5ClZ5MPWAYSgipjhPZMUU_iaimgQPpaUrMZ7vMD6vozTWTx9XibJ2lmH6UEUKbKkPUz8M6JoFwUJY7jIOnM5vI_o1cdMb3aYs1qFq-yFkwBxJQ7am-jEPMLcIJ7aL-QudD8Wtn0-Gkfh2ANRV1fHxsmrOGRdSMUYmZZ5GylPaUc9_2tiiWODEqIfLnH6KfPTDgBxL_yDZlwf5DNsRiY7tU2H8X2N4762v7tPOx7oSxes7n7Pw3f8C9pvtNDHg4TotNgn4lWxo9MeC5qScxBHKvCLThuSxw_HvVpfvmzZFxVRgDn2KofsoPjIYQpFECcQMRPwv_BbB2nr9h7YTA01ZafaAeQo.JRIacQ33ORp2UcZliCywBw).

---

<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:** [May 26, 2023, 11:09pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/5 "2023-05-26T23:09:10Z")

</div>

Hey thanks @collin1!

That looks to be an opaque token like you mentioned - Are you positive an audience param is getting passed?

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [May 27, 2023, 2:04pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/6 "2023-05-27T14:04:12Z")

</div>

Yes.

[https://dev-aoeuaoeuaoeuaoeu.us.auth0.com/authorize?client\_id=aoeuaoeuaoeuaoeuaeou&scope=openid%20profile%20email&response\_type=code&redirect\_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback&audience=https%3A%2F%2Fdev-aoeuaoeuaoeuaoeu.us.auth0.com%2Fapi%2Fv2%2F&nonce=aoeuaoeuaoeuaoeuaoeu&state=aoeuaoeuaoeuaeouaoeu&code\_challenge=aoeuaoeuaoeuaoeuaeou&code\_challenge\_method=S256](https://dev-aoeuaoeuaoeuaoeu.us.auth0.com/authorize?client_id=aoeuaoeuaoeuaoeuaeou&scope=openid%20profile%20email&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fapi%2Fauth%2Fcallback&audience=https%3A%2F%2Fdev-aoeuaoeuaoeuaoeu.us.auth0.com%2Fapi%2Fv2%2F&nonce=aoeuaoeuaoeuaoeuaoeu&state=aoeuaoeuaoeuaeouaoeu&code_challenge=aoeuaoeuaoeuaoeuaeou&code_challenge_method=S256)

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [May 31, 2023, 3:01pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/7 "2023-05-31T15:01:03Z")

</div>

Just following up - any thoughts on what may be causing this issue?

Collin

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 1, 2023, 12:55am UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/8 "2023-06-01T00:55:36Z")

</div>

Hi @collin1,

Thank you for your response. I am following up for @ty.frith.

I have just tested getting an Access Token with Next.js and did not experience any issues.

To investigate this issue further, could you please provide me the exact `/authorize` URL request you made and send it to me via direct messages?

For the moment, the URL you shared in [this reply](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/6) has obfuscated your tenant name. I would like to make sure that the request and your tenant settings are correct.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [June 1, 2023, 1:51pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/9 "2023-06-01T13:51:54Z")

</div>

Thanks, Rueben. I just sent over a message.

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [June 5, 2023, 3:50pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/10 "2023-06-05T15:50:21Z")

</div>

Hey all - just following up here.

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [June 12, 2023, 2:10pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/11 "2023-06-12T14:10:53Z")

</div>

Hey all - following up again

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [June 14, 2023, 3:34pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/12 "2023-06-14T15:34:27Z")

</div>

Last time following up. We won’t be able to use Auth0 as an authentication provider if this isn’t resolved.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 19, 2023, 3:43pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/13 "2023-06-19T15:43:13Z")

</div>

Hi @collin1,

Thank you for your updates. I have responded in our direct messages together with the provided solution. I am going to share the solution with the rest of the Community.

In essence, whenever the audience parameter is omitted in the login request, the token generated will be opaque. To get a JWT access token you must pass an `audience` parameter in the login request. For more information, I recommend reading our [Get Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/get-access-tokens#control-access-token-audience) documentation.

For clarity, the `/authorize` request should look something like the following:

```auto
https://{yourDomain}/authorize?
    response_type=code&
    client_id={yourClientId}&
    redirect_uri={https://yourApp/callback}&
    scope={scope}&
    audience={apiAudience}&
    state={state}

```

(Reference: [Call Your API Using the Authorization Code Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/call-your-api-using-the-authorization-code-flow))

I hope this helps!

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![collin1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/collin1/32/47241_2.png) [@collin1](https://community.auth0.com/u/collin1)\
**Post date:** [June 19, 2023, 5:57pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/14 "2023-06-19T17:57:31Z")

</div>

Hey Rueben - I have already confirmed that, please read the above messages and our private thread. I have started implementing frontegg and will move forward with their product if we are unable to resolve this issue before I finish.

Collin

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [June 21, 2023, 1:42am UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/15 "2023-06-21T01:42:06Z")

</div>

Hi @collin1,

Thanks for the reply!

I have just followed up with another response through our direct messages conversation.

---

<div class="post-metadata">

**Author:** ![diego.diaz](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/diego.diaz/32/50918_2.png) [@diego.diaz](https://community.auth0.com/u/diego.diaz)\
**Post date:** [September 15, 2023, 9:48pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/16 "2023-09-15T21:48:43Z")

</div>

Were there any updates regarding this? I’m running into the same issue

---

<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:** [May 20, 2024, 4:48pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/17 "2024-05-20T16:48:39Z")

</div>

A post was split to a new topic: [Missing Payload in Access Token with Next.js](https://community.auth0.com/t/missing-payload-in-access-token-with-next-js/134526)

---

<div class="post-metadata">

**Author:** ![alex.brett](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/alex.brett/32/60157_2.png) [@alex.brett](https://community.auth0.com/u/alex.brett)\
**Post date:** [November 20, 2024, 8:56pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/18 "2024-11-20T20:56:52Z")

</div>

Just a quick update on this case.

The issue was that the application was not granted access to the Management API. In most cases, if the token is opaque, then there was no audience passed into the call. Here is some documentation describing this.

> **[Get Access Tokens](https://auth0.com/docs/secure/tokens/access-tokens/get-access-tokens#control-access-token-audience)**
>
> Learn how to request Access Tokens using the Authorize endpoint when authenticating users and include the target audience and scope of access requested by the app and granted by the user.

I hope this helps!

Best,  
Alex

---

<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:** [December 4, 2024, 8:57pm UTC](https://community.auth0.com/t/empty-payload-in-access-token-with-next-js/107810/19 "2024-12-04T20:57:00Z")

</div>

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