# Cannot see the email in the access token AND userinfo Unauthorized

**URL:** <https://community.auth0.com/t/cannot-see-the-email-in-the-access-token-and-userinfo-unauthorized/90583>\
**Category:** Get Help\
**Tags:** jwt, auth0\
**Created:** [September 14, 2022, 10:30am UTC](https://community.auth0.com/t/cannot-see-the-email-in-the-access-token-and-userinfo-unauthorized/90583 "2022-09-14T10:30:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![loras](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/loras/32/39918_2.png) [@loras](https://community.auth0.com/u/loras)\
**Post date:** [September 14, 2022, 10:30am UTC](https://community.auth0.com/t/cannot-see-the-email-in-the-access-token-and-userinfo-unauthorized/90583/1 "2022-09-14T10:30:03Z")

</div>

Hi there,  
**SETUP** : python with FASTAPI, most of the code is copied from here: [Build and Secure a FastAPI Server with Auth0](https://auth0.com/blog/build-and-secure-fastapi-server-with-auth0/).  
**GOAL** : I want to be able to recognize/identify the user based on the token attached to the request.

I added the token rules [Add email to access token]: but I cannot see the email in the access token.  
I copied the code below from auth0 application test menu.  
**First problem** : I am able to receive the token, verify it ([Build and Secure a FastAPI Server with Auth0](https://auth0.com/blog/build-and-secure-fastapi-server-with-auth0/)) but the email is not inside the decoded token.  
**Second Problem** : I cannot get the userinfo, it says I am Unauthorized, despite I am using the access token got directly from Auth0. Am I missing something on the Auth0 dashboard? Something wrong in the code?

```auto

import http.client
    import json

    conn = http.client.HTTPSConnection("YOUR_DOMAIN")

    payload = "{\"client_id\":\"CLIENT_ID\",\"client_secret\":\"CLIENT_SECRET1\",\"audience\":\"YOUR_DOMAIN\",\"grant_type\":\"client_credentials\"}"

    headers = {'content-type': "application/json"}

    conn.request("POST", "/oauth/token", payload, headers)

    res = conn.getresponse()
    data = res.read()
    data = json.loads(data.decode("utf-8"))
    access_token = data['access_token']
    result = VerifyToken(token=access_token).verify()
    print(result)
    import requests

   
    url = "https://YOUR_DOMAIN/userinfo"
    headers = {
        'Authorization': f'Bearer {access_token}'
        # 'content-type': "application/json"
    }
    print('headers', headers)
    response = requests.request("GET", url, headers=headers)
    print(response.text)

```

---

<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 21, 2022, 12:41am UTC](https://community.auth0.com/t/cannot-see-the-email-in-the-access-token-and-userinfo-unauthorized/90583/3 "2022-09-21T00:41:46Z")

</div>

Hello there @loras welcome to the community!

I apologize for the delayed response, but wanted to check to see if you were able to resolve this issue?

> [@loras](#):
>
> I am able to receive the token, verify it ([Build and Secure a FastAPI Server with Auth0](https://auth0.com/blog/build-and-secure-fastapi-server-with-auth0/)) but the email is not inside the decoded token.

How are you getting the Access/ID Token? The tutorial just grabs the access token from the “test” section of the API settings which is for a client credentials flow and will therefore not be associated with a user and thus have no /userinfo audience (required to use the access token against the [userinfo endpoint](https://auth0.com/docs/api/authentication#user-profile)).

Let us know!

---

<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:** [November 22, 2022, 10:48pm UTC](https://community.auth0.com/t/cannot-see-the-email-in-the-access-token-and-userinfo-unauthorized/90583/4 "2022-11-22T22:48:24Z")

</div>

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