# Auth0: passing custom fields in getAccessTokenSilently in order to be used in rules

**URL:** <https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605>\
**Category:** Get Help\
**Created:** [June 21, 2022, 8:30am UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605 "2022-06-21T08:30:37Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharbel.shuker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sharbel.shuker/32/38194_2.png) [@sharbel.shuker](https://community.auth0.com/u/sharbel.shuker)\
**Post date:** [June 21, 2022, 8:30am UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/1 "2022-06-21T08:30:37Z")

</div>

We are using Auth0 SDK and trying to include a custom option to rule/access-token after login. The purpose is to be able to inject dynamic params into payload from rules. Client is a react.js app and we use @auth0/auth0-react library. Noticed that getAccessTokenSilently is extensible to include custom params:

```auto
const { getAccessTokenSilently } = useAuth0();
const accessToken = await getAccessTokenSilently({
        audience: 'myaudience',
        scope: 'read:read_users',
        'foo': 'bar'
    });

```

The question is, how do we get access to foo=bar from inside the rules? Thanks

P.S: [solution](https://community.auth0.com/t/passing-user-option-to-rule-access-token-after-login/64779) this could not help solve our problem.

---

<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:** [June 27, 2022, 5:35pm UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/3 "2022-06-27T17:35:58Z")

</div>

Hi @sharbel.shuker,

Welcome to the Auth0 Community!

You should be able to see the request params in the `context.request.query` object.

Are you not seeing them in your rule?

---

<div class="post-metadata">

**Author:** ![sharbel.shuker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sharbel.shuker/32/38194_2.png) [@sharbel.shuker](https://community.auth0.com/u/sharbel.shuker)\
**Post date:** [June 28, 2022, 6:18am UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/4 "2022-06-28T06:18:31Z")

</div>

Hi @dan.woda  
no, unfortunately, I can not see these variables in the rules.  
only if this variable is specified within the Auth0Provider.  
is it possible to pass it while requesting a token?

---

<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:** [June 28, 2022, 4:25pm UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/5 "2022-06-28T16:25:08Z")

</div>

Hi @sharbel.shuker,

After some testing, I can’t seem to get them to show up either. Let me reach out to our team and see if I can get to the bottom of it. I’ll report back when I have an answer.

---

<div class="post-metadata">

**Author:** ![sharbel.shuker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sharbel.shuker/32/38194_2.png) [@sharbel.shuker](https://community.auth0.com/u/sharbel.shuker)\
**Post date:** [June 30, 2022, 7:20am UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/6 "2022-06-30T07:20:52Z")

</div>

Hi @dan.woda ,

That would be great, many thanks in advance 🙂

---

<div class="post-metadata">

**Author:** ![richlee](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@richlee](https://community.auth0.com/u/richlee)\
**Post date:** [March 6, 2023, 5:01am UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/7 "2023-03-06T05:01:58Z")

</div>

Hey @dan.woda , what was the outcome of your investigations?

I’m facing the same issue - custom params passed to `getAccessTokenSilently` function are not appearing in the context.request.query…

I’m using version 1.12.0 of @auth0/auth0-react  
And version 1.21.1 of @auth0/auth0-spa-js

Thanks

---

<div class="post-metadata">

**Author:** ![sharbel.shuker](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/sharbel.shuker/32/38194_2.png) [@sharbel.shuker](https://community.auth0.com/u/sharbel.shuker)\
**Post date:** [March 6, 2023, 7:18am UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/8 "2023-03-06T07:18:47Z")

</div>

@richlee  
for me, i am using “@auth0/auth0-react”: “^1.8.0”,  
adding ignoreCache: true as follow should work  
getAccessTokenSilently({  
ignoreCache: true,  
‘foo’: ‘bar’  
})

---

<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 6, 2023, 2:00pm UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/9 "2023-03-06T14:00:02Z")

</div>

Thanks for sharing your solution @sharbel.shuker

---

<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 24, 2023, 1:47pm UTC](https://community.auth0.com/t/auth0-passing-custom-fields-in-getaccesstokensilently-in-order-to-be-used-in-rules/85605/10 "2023-04-24T13:47:53Z")

</div>

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