# How do i get claims from access token in @auth0/nextjs lib?

**URL:** <https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379>\
**Category:** Get Help\
**Created:** [September 27, 2022, 1:39pm UTC](https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379 "2022-09-27T13:39:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![danyo](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@danyo](https://community.auth0.com/u/danyo)\
**Post date:** [September 27, 2022, 1:39pm UTC](https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379/1 "2022-09-27T13:39:20Z")

</div>

Hi there i have a nextjs app and we have roles / permission setup. I return the permissions in the access token as a claim. Is there a way to read them from the nextjs api?

I found a getSession but all it returns is the encoded JWT access token.

Thanks in advance

---

<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:** [September 29, 2022, 12:19am UTC](https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379/3 "2022-09-29T00:19:54Z")

</div>

Hey there @danyo welcome to the community!

> [@danyo](#):
>
> Is there a way to read them from the nextjs api?
> 
> I found a getSession but all it returns is the encoded JWT access token.

Where is exactly in your app are you looking to access the permissions? If you can elaborate on your use case a bit that could be helpful.

The following post may have the answer(s) you are looking for:

> [@Token in appSession cookie cannot be decoded](https://community.auth0.com/t/token-in-appsession-cookie-cannot-be-decoded/60591/5):
>
> I was referring to the part of the token before the first period. For example, if you paste this token in [jwt.io/](http://jwt.io/), you’ll see the header decoded, but not the payload: eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIiwiaWF0IjoxNjE3ODAzNDc5LCJ1YXQiOjE2MTc4ODE3MjUsImV4cCI6MTYxNzk2ODEyNX0..TIKxzG4pPsaR94xs.OcYKxDstl98CUxx9NfgjfBMNwjxChdT8CPP0ieAW6ODsBXBFaoPCIgBwGrZMxzDctd2nQs0eG52q1FGynbh4zmD1\_\_Wu5zLlUHBojHCZB-kuJPLP-kzMxggr9dpQ7oZL02MgUh689Kh3byV6513QG3JSWw7kOmlll7o87aGrEShDPIxvaprHlDfM2iCfq9GJU0UuqHIhRAqWu…

Let us know!

---

<div class="post-metadata">

**Author:** ![danyo](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@danyo](https://community.auth0.com/u/danyo)\
**Post date:** [October 3, 2022, 9:30pm UTC](https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379/4 "2022-10-03T21:30:01Z")

</div>

Hi tyf.  
I was looking to access the permissions from the nextjs server api.

I want to create an identity api endpoint which returns the permissions along with some other user data that is only stored in the access token so i can tailor the ui display based on a users permissions.

In the end i just went with the authorized scopes since they are available in the api. Seems to work okay.

---

<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:** [October 11, 2022, 11:22pm UTC](https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379/5 "2022-10-11T23:22:26Z")

</div>

Hey @danyo apologize for the delayed response here, but thanks a bunch for following up with the community!

> [@danyo](#):
>
> In the end i just went with the authorized scopes since they are available in the api. Seems to work okay.

This is a totally valid approach - It’s common to infer permissions this way based on scopes.

---

<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:** [October 25, 2022, 11:23pm UTC](https://community.auth0.com/t/how-do-i-get-claims-from-access-token-in-auth0-nextjs-lib/91379/6 "2022-10-25T23:23:16Z")

</div>

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