Support getAccessTokenSilently
for multiple audiences in parallel
#1253
Labels
feature request
A feature has been asked for or suggested by the community
Checklist
Describe the problem you'd like to have solved
It's impossible in the current implementation to get an access token for multiple different audiences in parallel, as the client acquires a global lock prior to fetching a token. We have the following code snippet:
But in practice, all of the networking is sequential. Since the page cannot fully load until both tokens are available, this adds delays that are impossible to reduce with the current implementation.
Describe the ideal solution
If I call
getAccessTokenSilently
in parallel with two different audiences, I would like the resulting network request to fire in parallel.Alternatives and current workarounds
Using localStorage caching is an alternative we've considered, but does not solve the initial login flow when the tokens are not cached, and has obvious security implications.
I've seen recommendations for changing the structure to use scopes instead of audiences, and relying on a single token, but I'd like to keep separate tokens for each of the APIs.
Additional context
Here's a screenshot of the chrome profiler, you can see a lot of time being spent waiting for some of these token calls to come back (the
authorize
andtoken
network calls are all auth0)We're working on improvements to the load times of our dashboard, and this is the biggest contributor to latency. The 3 consecutive authentication iframe flows take a combined 2-3 seconds, which adds noticeable delay.
It seems like the lock was implemented to avoid multiple processes fetching the same token, but it seems logical that we could fetch tokens for different audiences in parallel, reducing the impact of these expensive network calls.
The text was updated successfully, but these errors were encountered: