This case works fine if the option is specified before user’s login (i.e. before loginWithRedirect). I was wondering if it’d be possible to pass in custom options to the rule/access-token after a user’s login. I tried that with getTokenSilently:
but it seems useroption doesn’t appear in context.request. Any idea if that should work or could be made to work? If no, any other suggestions to achieve the same effect?
In order to persist the user options after a user logs in, you’d likely need to save the user options in the user’s metadata in the rule with something like:
Thanks @stephanie.chamblee! Just to clarify, I was wondering if it’d be possible the user option to appear in rule’s context.request as part of calling getTokenSilently (or perhaps another method except loginWithRedirect). Any idea if that’d be possible?
I just tested this out, and it looks like when you pass custom parameters in the auth0.getTokenSilently, they are accessible in the rule in context.request.query:
This request will pull the token from memory when a valid one is available, so it is possible that the rule will not run if there is a valid token available.
I think the problem in my case was the token cache in the SDK. If cache is disabled it seems passing options to getTokenSilently works fine. Thank you!