Fetching multiple access tokens silently only succeeds for one token
See original GitHub issueI’m submitting a…
[x] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
Browser:
- Chrome version XX
- Firefox version XX
- IE version XX
- Edge version XX
- Safari version XX
Library version
Library version: 1.0.0
Current behavior
When trying to fetch two access tokens silently at the same time after a login, only one of the responses actually includes the access token. When refreshing, one token gets fetched from the cache which makes the other token response succeed.
Expected behavior
Both token responses should succeed in getting the token.
Minimal reproduction of the problem with instructions
const msal = new Msal.UserAgentApplication(config);
// after a user has logged in
msal.acquireTokenSilent({ scopes: ['user.read'] })
.then(response => {
// do something with access token
})
msal.acquireTokenSilent({ scopes: ['api://myapiguid/Read'] })
.then(response => {
// do something with access token
})
When doing the above, either of the responses will not contain an access token, as they are being run at the same time. This used to work in the previous version of msal, 0.2.4 if I recall correctly.
When doing the following workaround, the tokens are being acquired correctly:
msal.acquireTokenSilent({ scopes: ['user.read'] })
.then(response => {
// do something with access token
return msal.acquireTokenSilent({ scopes: ['api://myapiguid/Read'] });
})
.then(response => {
// do something with access token
})
Which suggests that the tokens are not being successfully acquired when attempting to do so at the same time.
Edit: After some more testing, it correctly delays one request until the other one is done. I’m not really sure why, but before the issue happened as explained above. I’m not sure if something changed that affected this, so I’m leaving the issue open in case it happens again.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top GitHub Comments
@raikoss @ThomasJacob Re-opening because I was able to repro. I have added a fix for this in PR #768. Can you please check if this fixes your issue? I will push a patch as soon as I have confirmed that it sufficiently fixes the issue.
The changes in the pull request seems to fix the issue.