# I am not getting email from my accessToken

**URL:** <https://community.auth0.com/t/i-am-not-getting-email-from-my-accesstoken/103322>\
**Category:** JWT.io\
**Tags:** jwt, api, rules, auth0\
**Created:** [March 25, 2023, 2:23pm UTC](https://community.auth0.com/t/i-am-not-getting-email-from-my-accesstoken/103322 "2023-03-25T14:23:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![olusanya](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@olusanya](https://community.auth0.com/u/olusanya)\
**Post date:** [March 25, 2023, 2:23pm UTC](https://community.auth0.com/t/i-am-not-getting-email-from-my-accesstoken/103322/1 "2023-03-25T14:23:20Z")

</div>

Hello,

I am using NextJS for frontend and NestJS for backend. I created a custom claim to get email in my acessToken.

```auto
exports.onExecutePostLogin = async (event, api) => {
  // This adds the authenticated user's email address to the access token.
  if (event.authorization) {
    const namespace = 'http://localhost:3000';
    api.accessToken.setCustomClaim(`${namespace}/claims/email`, event.user.email);
  }
};

```

This is what I am getting from [jwt.io](http://jwt.io):

```auto
{
  "iss": "https://dev-escroid-1.us.auth0.com/",
  "sub": "DjoYwj2Xh3tbnoysfn3nQUrY2LAVwDP5@clients",
  "aud": "http://localhost:3000",
  "iat": 1679752328,
  "exp": 1679838728,
  "azp": "DjoYwj2Xh3tbnoysfn3nQUrY2LAVwDP5",
  "gty": "client-credentials",
  "permissions": []
}

```

On next js, I am using this library from auth0:

```auto
import { handleAuth, handleLogin, handleCallback } from "@auth0/nextjs-auth0";

  export default handleAuth({
  login: handleLogin({
    authorizationParams: {
      audience: process.env.AUDIENCE, // or AUTH0_AUDIENCE
      // Add the `offline_access` scope to also get a Refresh Token
     scope: 'openid profile email' // or AUTH0_SCOPE
    }
  })
});  

```

I am using this code to get my accessToken from Auth0 after login:

```auto
 var options = {
      method: "POST",
      url: 'https://dev-escroid-1.us.auth0.com/oauth/token',
      headers: { 'content-type': 'application/json' },
      body: '{"client_id":"ID","client_secret":"Secret","audience":"http://localhost:3000","grant_type":"client_credentials"}' };
    

    request(options, async function (error, response, body) {
      console.log("res", body)

```

Please how can I get email and ID in my nextJS accessToken

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [March 29, 2023, 7:54pm UTC](https://community.auth0.com/t/i-am-not-getting-email-from-my-accesstoken/103322/3 "2023-03-29T19:54:33Z")

</div>

Hi @olusanya,

Welcome to the Auth0 Community!

A client credentials grant is a user-less grant type that covers Machine to Machine auth. The reason you aren’t getting an email is because there is no user involved.

Let me know if you have any questions.

---

<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:** [April 12, 2023, 7:55pm UTC](https://community.auth0.com/t/i-am-not-getting-email-from-my-accesstoken/103322/4 "2023-04-12T19:55:04Z")

</div>

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