# Access the raw Access Token/JWT in my backend API and get all claims

**URL:** <https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869>\
**Category:** Get Help\
**Tags:** apis, application\
**Created:** [February 20, 2023, 4:56pm UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869 "2023-02-20T16:56:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andreas.lundgren](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andreas.lundgren/32/44775_2.png) [@andreas.lundgren](https://community.auth0.com/u/andreas.lundgren)\
**Post date:** [February 20, 2023, 4:56pm UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869/1 "2023-02-20T16:56:49Z")

</div>

I have some custom state encoded as a claim in my Access Token (JWT) for **quick access** in the backend. User is logged in via our SPA or apps, and sends the Access Token to the Backend. I have backend in Node/JS and in Python, but in the provided SDK:s, I cannot find a method to fetch back the provided claims (with my custom “state”) in the JWT.

I can of course just read the token from the request header myself, maybe that is the recommended way?

**Details**  
I use a Login Flow of Auth0 to attach some more information to the JWT. This will speed up my backend as the most used pieces of the state is stored directly in the JWT. Now most backend calls can be served after just examining the JWT, without the delay of getting additional user info from the auth0 API or from some session cache in my backend.

Switching from a proprietary solution to auth0, I have a hard time finding a method in any of the backend SDK:s to fetch back the claims from the access token. From the Frontend I can verify that the JWT is correct using (from the example code) `auth0Client.getTokenSilently()`. In the backend, this method is not usable since I don’t want for a new token, just access the one that was attached in the Authorization Bearer header of the request.

---

<div class="post-metadata">

**Author:** ![spoudel](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/spoudel/32/51376_2.png) [@spoudel](https://community.auth0.com/u/spoudel)\
**Post date:** [February 20, 2023, 8:07pm UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869/2 "2023-02-20T20:07:06Z")

</div>

You could access the claims of token from User Object. Hopefully, this link answers your question.

> **[RequestContext | express-openid-connect](https://auth0.github.io/express-openid-connect/interfaces/RequestContext.html#idToken)**
>
> Documentation for express-openid-connect

---

<div class="post-metadata">

**Author:** ![andreas.lundgren](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andreas.lundgren/32/44775_2.png) [@andreas.lundgren](https://community.auth0.com/u/andreas.lundgren)\
**Post date:** [February 21, 2023, 5:43am UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869/3 "2023-02-21T05:43:07Z")

</div>

Sorry for missing an important piece, I let the user authenticate in an SPA. This is not a Machine-to-machine authentication. So in the backend, I don’t have access to the `ID Token`. Only the `Access Token`.

I send the `Access Token` to the backend, like this in my frontend/browser code:

```auto
    // Get the access token from the Auth0 client
    const token = await auth0Client.getTokenSilently();

    // Make the call to the API, setting the token
    // in the Authorization header
    const response = await fetch("/api/external", {
      headers: {
        Authorization: `Bearer ${token}`
      }
    });

```

---

<div class="post-metadata">

**Author:** ![andreas.lundgren](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/andreas.lundgren/32/44775_2.png) [@andreas.lundgren](https://community.auth0.com/u/andreas.lundgren)\
**Post date:** [March 2, 2023, 8:32am UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869/4 "2023-03-02T08:32:03Z")

</div>

To answer my own question for the future, The Access Token, unless specified to be opaque as per [this description](https://auth0.com/docs/secure/tokens/access-tokens/get-access-tokens#control-access-token-audience), is a regular JWT as per [this description](https://auth0.com/docs/secure/tokens/access-tokens#jwt-access-tokens).

Thus any library, for example one listed on [jwt.io](https://jwt.io/libraries) can be used to extract claims (and validate) an Access Token. For some languages/frameworks, Auth0 specific libraries seams to exist, like [Node Express](https://auth0.github.io/node-oauth2-jwt-bearer/#claimcheck)

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [March 2, 2023, 11:54am UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869/5 "2023-03-02T11:54:33Z")

</div>

Thanks for sharing it with the rest of community!

---

<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:** [March 16, 2023, 11:55am UTC](https://community.auth0.com/t/access-the-raw-access-token-jwt-in-my-backend-api-and-get-all-claims/100869/6 "2023-03-16T11:55:06Z")

</div>

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