# Bug: Access token missing custom fields added in rule

**URL:** <https://community.auth0.com/t/bug-access-token-missing-custom-fields-added-in-rule/9235>\
**Category:** Get Help\
**Tags:** jwt, rules, bug, access-token\
**Created:** [January 18, 2018, 6:33pm UTC](https://community.auth0.com/t/bug-access-token-missing-custom-fields-added-in-rule/9235 "2018-01-18T18:33:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan.kopriva](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@dan.kopriva](https://community.auth0.com/u/dan.kopriva)\
**Post date:** [January 18, 2018, 6:33pm UTC](https://community.auth0.com/t/bug-access-token-missing-custom-fields-added-in-rule/9235/1 "2018-01-18T18:33:59Z")

</div>

Hi,  
About month ago I have [similar isussue](http://community.auth0.com/questions/12842/jwt-token-isnt-saved-in-rule#) with version 10.24. and problem is the same in version 11. I try to describe it little more.

Version Auth0-lock: **11.0.1**

Configuration:

```
 {
          leeway: 30, 
          theme: {
            primaryColor: '#6e40ff',
            logo: logoImage
          },
          allowShowPassword: true,
          languageDictionary: {
            title: '',
            signUpTerms: "I agree to the..."
          },
          mustAcceptTerms: true,
          autoclose: true,
          rememberLastLogin: true,
          auth: {
            redirectUrl: 'http://localhost:9000/login',
            autoParseHash: true,
            sso: true,
            responseType: 'token',
            audience: 'https://api.example.io'
          }
}

```

Rule is still the same as before:

```
function (user, context, callback) { 
      console.log('add-user_metadata-to-token_id - start');
      console.log('add-user_metadata-to-token_id - user ', user);
      console.log('add-user_metadata-to-token_id - context: ', context);
     
      var namespace = 'https://example.io/';          
      context.accessToken[namespace + 'email'] = user.email;
      context.accessToken[namespace + 'organizationId'] = user.user_metadata.organization;
         
      console.log('add-user_metadata-to-token_id - idToken', context.idToken);
      console.log('add-user_metadata-to-token_id - accessToken', context.accessToken);
      
      callback(null, user, context);
    }

```

Problem:

When I create user over Auth0 administration or using signup proccess on embed Lock signup page, after first login my accessToken doesn’t contains fields **email** and **organizationId**.

Access token after first login:

> **[Gyazo](https://gyazo.com/f2a1c135e8e52ed24131beafa53ea129)**
>
> Gyazo is the easiest way to record screenshots & videos you can share instantly. Save time with async visual communication that's effortless and engaging.

Access token after second and more logins:

> **[Gyazo](https://gyazo.com/ca6b87901342411c1e253bb44d09feb7)**
>
> Gyazo is the easiest way to record screenshots & videos you can share instantly. Save time with async visual communication that's effortless and engaging.

Thanks  
Dan

---

<div class="post-metadata">

**Author:** ![richard.dowinton](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/richard.dowinton/32/16150_2.png) [@richard.dowinton](https://community.auth0.com/u/richard.dowinton)\
**Post date:** [March 5, 2018, 12:37pm UTC](https://community.auth0.com/t/bug-access-token-missing-custom-fields-added-in-rule/9235/2 "2018-03-05T12:37:47Z")

</div>

Have you made sure that the `user.email` and `user.user_metadata.organization` both exist and aren’t `null`? Also, have you tried specifying `openid email` in the `scope` when you request the access token?

---

<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:** [July 25, 2019, 11:03am UTC](https://community.auth0.com/t/bug-access-token-missing-custom-fields-added-in-rule/9235/3 "2019-07-25T11:03:48Z")

</div>


