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

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.

Welcome to the Community!

You should be able to add custom params like this:

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.

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:

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

Can someone please suggest what’s wrong here.

Thanks,
Hari.

I am able to get this to work using the Vanilla JS ‘Call An API’ Quickstart, using this code:

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

Screen Shot 2021-05-21 at 9.45.32 AM

1 Like

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