# Nextjs-auth0 /api/auth/me route doesn't return as many details as expected

**URL:** <https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299>\
**Category:** Get Help\
**Tags:** user\_metadata, user-profile, nextjs, auth0\
**Created:** [January 16, 2021, 10:04am UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299 "2021-01-16T10:04:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvxt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mvxt/32/12906_2.png) [@mvxt](https://community.auth0.com/u/mvxt)\
**Post date:** [January 16, 2021, 10:04am UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299/1 "2021-01-16T10:04:23Z")

</div>

- **Which SDK this is regarding:** nextjs-auth0
- **SDK Version:** 1.0.0-beta.0, 0.16.0
- **Platform Version:** e.g. Node v15.0.1
- **Code Snippets/Error Messages/Supporting Details/Screenshots:**

I’m new to Auth0 so this might be a newb question. When I look at a user’s raw JSON directly in Auth0, I can see various details like email, email\_verified, identities, etc. But when accessing the `/api/auth/me` API route in the Next.js-Auth0 SDK, it only returns a few parameters like nickname, name, and picture, among a few others.

Is this an issue with configuration on admin side? I also noticed that when I register a user, the email address is put into the “name” field for some reason. At the very least, I need to be able to fetch the user’s email and metadata as part of the profile. Any assistance/advice is appreciated.

Thanks ahead of time for the help!

---

<div class="post-metadata">

**Author:** ![mvxt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mvxt/32/12906_2.png) [@mvxt](https://community.auth0.com/u/mvxt)\
**Post date:** [January 17, 2021, 6:34am UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299/2 "2021-01-17T06:34:27Z")

</div>

**UPDATE** :  
Seems like I’ve found a starting point. Still not clear whether it’s my user error or if there’s an inconsistency, but the details can be found here in this issue I filed in the repo:

[https://github.com/auth0/nextjs-auth0/issues/240](https://github.com/auth0/nextjs-auth0/issues/240)

Essentially, I had to manually specify `authorizationParams` for the login:

```
import { handleAuth, handleLogin } from '@auth0/nextjs-auth0';

export default handleAuth({
  async login(req, res) {
    try {
      await handleLogin(req, res, { 
        returnTo: '/dashboard',
        authorizationParams: {
          response_type: 'code',
          scope: 'openid profile email',
        }
      });
    } catch (error) {
      res.status(error.status || 500).end(error.message);
    }
  }
});

```

---

<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:** [January 18, 2021, 5:48pm UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299/3 "2021-01-18T17:48:05Z")

</div>

I pinged the repo maintainer regarding your issue so they should look at that shortly!

---

<div class="post-metadata">

**Author:** ![mvxt](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/mvxt/32/12906_2.png) [@mvxt](https://community.auth0.com/u/mvxt)\
**Post date:** [February 10, 2021, 8:22am UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299/4 "2021-02-10T08:22:05Z")

</div>

I figured out the problem. It was user error. Derp derp.

When running Auth0 on Next.js, you have the ability to set various parameters [via environment variables](https://auth0.github.io/nextjs-auth0/modules/config.html#1-environmental-variables). I had completely forgotten I’d set the scope in there.

So my `.env.local` file had this:

```auto
...
AUTH0_SCOPE="openid profile"
...

```

And subsequently, the default behavior was not showing the user’s email. However, it looks like specifying it explicitly in the API routes does override the environment variable.

```auto
const cryptoRandomString = require('crypto-random-string');
import { handleAuth, handleLogin, handleProfile } from '@auth0/nextjs-auth0';

export default handleAuth({
  async login(req, res) {
    try {
      await handleLogin(req, res, { 
        returnTo: '/dashboard',
        authorizationParams: {
          response_type: 'code',
          scope: 'openid profile email',
        }
      });
    } catch (error) {
      res.status(error.status || 500).end(error.message);
    }
  },
  ...

```

The above does return the user’s email information at `/api/auth/me` regardless of how the ENV variables were set up.

---

<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:** [February 10, 2021, 12:45pm UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299/5 "2021-02-10T12:45:09Z")

</div>

Perfect glad you have figured it out and thanks for sharing with the rest of community!

---

<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:** [February 25, 2021, 10:23am UTC](https://community.auth0.com/t/nextjs-auth0-api-auth-me-route-doesnt-return-as-many-details-as-expected/56299/6 "2021-02-25T10:23:29Z")

</div>


