# Custom Parameters not available in Rules context while using gettokensilently()

**URL:** <https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885>\
**Category:** Get Help\
**Tags:** auth0-spa-js, react, token, id\_token, access-token\
**Created:** [May 16, 2021, 10:16am UTC](https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885 "2021-05-16T10:16:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![harigovind2295](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/harigovind2295/32/29455_2.png) [@harigovind2295](https://community.auth0.com/u/harigovind2295)\
**Post date:** [May 16, 2021, 10:16am UTC](https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885/1 "2021-05-16T10:16:43Z")

</div>

Hi Team,

I am using auth0-spa-js library in my React app .

Once after authenticating initially, I want to generate access tokens for other users as part of my requirement , for which I need to add different email addresses in context object in Auth0 rules. Currently I am trying to use gettokensilently method in auth0-spa-js library by adding custom Parameters in it. But I am not able to get the added custom Parameters in Auth0 rules.

How exactly can I achieve my requirement or is there any other way to do it effectively. Can anyone please give your suggestions.

Thanks,  
Hari.

---

<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:** [May 17, 2021, 11:43pm UTC](https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885/3 "2021-05-17T23:43:44Z")

</div>

Welcome to the Community!

You should be able to add custom params like this:

```auto
getTokenSilently({foo:'bar'})

```

It is possible that getTokenSilently is getting a cached access token and is avoiding the rules flow because it doesn’t need to make a new request.

---

<div class="post-metadata">

**Author:** ![harigovind2295](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/harigovind2295/32/29455_2.png) [@harigovind2295](https://community.auth0.com/u/harigovind2295)\
**Post date:** [May 21, 2021, 5:49am UTC](https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885/4 "2021-05-21T05:49:57Z")

</div>

Hi There,

Thanks for the reply. It works when I explicitly pass the custom parameters into getTokenSliently method as given in the example above.

But when I try to spread the custom parameters into the method it doesn’t work. Please find the example below:

```javascript
customParams = { foo: 'bar', vehicle: 'car' }
getTokenSilently({ ignoreCache: true , ...customParams});

```

Can someone please suggest what’s wrong here.

Thanks,  
Hari.

---

<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:** [May 21, 2021, 4:48pm UTC](https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885/5 "2021-05-21T16:48:07Z")

</div>

I am able to get this to work using the [Vanilla JS ‘Call An API’ Quickstart](https://auth0.com/docs/quickstart/spa/vanillajs/02-calling-an-api), using this code:

```javascript
    const customParams = { foo:'bar', color: 'blue' }
    const token = await auth0.getTokenSilently({ignoreCache: true, ...customParams});

```

![Screen Shot 2021-05-21 at 9.45.32 AM](https://global.discourse-cdn.com/auth0/original/3X/d/a/da9c2d5d9d53fac76f8d3184d6ec726aadb683a0.png)

---

<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:** [June 5, 2021, 4:48pm UTC](https://community.auth0.com/t/custom-parameters-not-available-in-rules-context-while-using-gettokensilently/62885/6 "2021-06-05T16:48:42Z")

</div>

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