# Calling webAuth.client.login does not include user\_metadata in the ID token

**URL:** <https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763>\
**Category:** Get Help\
**Tags:** webauth, user\_metadata, id\_token\
**Created:** [May 26, 2017, 8:47pm UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763 "2017-05-26T20:47:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivojinovic](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ivojinovic](https://community.auth0.com/u/ivojinovic)\
**Post date:** [May 26, 2017, 8:47pm UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763/1 "2017-05-26T20:47:31Z")

</div>

When I use Lock like this:

```
var lock = new Auth0Lock('clientId', 'domain', {
    auth: {
        params: {
            scope: 'openid email user_metadata'
        },
        redirect: false
    }
});

```

in the response I receive `id_token` with `user_metadata` in it.

However, when I use Auth0.js like this:

```
webAuth = new auth0.WebAuth({
    clientID: 'clientId',
    domain: 'domain',
    responseType: 'id_token',
    scope: 'openid email user_metadata'
});

webAuth.client.login({
    realm: 'clientDb',
    username: 'username',
    password: 'password'
}, function(err, authResult){
    console.log(authResult)
});

```

there is no `user_metadata` in the `id_token` from the response.

Am I dong something wrong? Is there a way to get `user_metadata` in `id_token` provided by `webAuth.client.login` or do I have to use Lock?

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [May 26, 2017, 9:48pm UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763/2 "2017-05-26T21:48:05Z")

</div>

**TL;DR** The approaches mentioned use different underlying authentication endpoints/methods that result in the different behavior. See the docs about the [introduction of OIDC conformant authentication](https://auth0.com/docs/api-auth/intro).

* * *

**When using non-OIDC conformant authentication** (aka _legacy_ and the one being used with the Lock configuration you mentioned) then including `user_metadata` as one of the requested scopes would lead to the user metadata being included in the issued ID token.

**When using OIDC conformant authentication** (aka _new_ and the one being used with the Auth0.js configuration you mentioned) then the contents of the ID token will not include the `user_metadata` as a claim even if you request it as part of the scope. This is due to the fact that `user_metadata` is not a standard OIDC claim.

**In the OIDC mode you can include custom claims in the issued token**. For reference information on how to include custom claims see:

> **[OpenID Connect Scopes](https://auth0.com/docs/get-started/apis/scopes/openid-connect-scopes)**
>
> Understand scopes and claims used with the OpenID Connect (OIDC) protocol.

---

<div class="post-metadata">

**Author:** ![David\_Ascher](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/david_ascher/32/6182_2.png) [@David\_Ascher](https://community.auth0.com/u/David_Ascher)\
**Post date:** [May 26, 2017, 11:16pm UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763/3 "2017-05-26T23:16:30Z")

</div>

But, in OIDC mode (which is automatic with Auth0.js v8 AFAICT?) we can’t access the user\_metadata in that rule because it’s been stripped from the user object before the rule gets called.

---

<div class="post-metadata">

**Author:** ![David\_Ascher](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/david_ascher/32/6182_2.png) [@David\_Ascher](https://community.auth0.com/u/David_Ascher)\
**Post date:** [May 26, 2017, 11:16pm UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763/4 "2017-05-26T23:16:30Z")

</div>

But, in OIDC mode (which is automatic with Auth0.js v8 AFAICT?) we can’t access the user\_metadata in that rule because it’s been stripped from the user object before the rule gets called.

---

<div class="post-metadata">

**Author:** ![jmangelo](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jmangelo/32/7923_2.png) [@jmangelo](https://community.auth0.com/u/jmangelo)\
**Post date:** [May 29, 2017, 2:56pm UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763/5 "2017-05-29T14:56:13Z")

</div>

OIDC mode is _automatic_ when doing API authorization (aka audience parameter) requests. Auth0.js v8 supports API authorization, but does not impose it to you so you can still make requests without the audience parameter and as such that request may not be using OIDC mode. The problem you describe also seems unrelated to OIDC mode as it’s happening on a rule which should have access to user metadata in both modes.

---

<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 2, 2018, 5:54am UTC](https://community.auth0.com/t/calling-webauth-client-login-does-not-include-user-metadata-in-the-id-token/6763/6 "2018-03-02T05:54:08Z")

</div>


