Microsoft-authentication-library-for-js: [performance | bug] acquireTokenSilent is always talking to azure

Created on 14 Jun 2019  路  11Comments  路  Source: AzureAD/microsoft-authentication-library-for-js

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:

Browser:

  • [x] Chrome version: Version 75.0.3770.90 (Official Build) (64-bit)
  • [ ] Firefox version XX
  • [ ] IE version XX
  • [ ] Edge version XX
  • [ ] Safari version XX

Library version


Library version: 1.0.0 and 1.0.1

Current behavior


it seems acquireTokenSilent is always trying to get the accessToken from azure, instead of local cache. I can see acquireTokenSilent sends request to https://login.microsoftonline.com/te/... everytime my code calls it.

I can get a solid repro using this azure sample:
https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp

Expected behavior


acquireTokenSilent gets token from azure for first time, and subsequently it gets token from browser cache

Minimal reproduction of the problem with instructions

  1. clone code from offcial sample: https://github.com/Azure-Samples/active-directory-b2c-javascript-msal-singlepageapp
  2. make necessary changes (clientId, authority, etc...)
  3. start web app
  4. click login
  5. click call web api
  6. click call web api
  7. click call web api

image

b2c bug performance

Most helpful comment

more and more users complains about this, especially when MSAL have to request and update two tokens (for Graph and SharePoint Online) in the same time.

https://antongorbikov.wordpress.com/2019/07/01/migrating-from-adal-to-msal/

All 11 comments

@pkanher617 is this related to authority and the cache?

@rick-hayek I will take a look at this today. Thank you for the detailed repro.

I'm seeing this behavior in my application as well. It creates a noticeable drag on performance since there's a slight delay every time a token is requested.

We also faced this issues. Currently, we developed our own Promise-wrapper that cache promise from acquireTokenSilent.

At the start of out app, we send 4 calls to MS Graph, each calls acquireTokenSilent and app initiate 4 auth processes (almost simultaneously). Some of them fail and leave garbage in local storage (key-values from not-finished authentications). All further calls reload iframe to acquire new token as mentioned in this issues.

I think it's also worth noting that this issue further exacerbates the issue reported in #317. Every time a token request is made instead of using the one in cache, it also triggers an additional unnecessary request for the OpenID configuration.

more and more users complains about this, especially when MSAL have to request and update two tokens (for Graph and SharePoint Online) in the same time.

https://antongorbikov.wordpress.com/2019/07/01/migrating-from-adal-to-msal/

This is definitely something we are focused on fixing @jasonnutter is helping drive the investigation

I'm no longer seeing this issue after upgrading to v1.1.2. Anyone else?

Updating to v1.1.2 seems to have corrected the issue for me too.

I'm no longer seeing this issue after upgrading to v1.1.2. Anyone else?

Same here, no issues using 1.1.2

Looks like @pkanher617 's fix for scopes helped improve this. @pkanher617 If you confirm the same, we can tag this issue closed with #875.

Was this page helpful?
0 / 5 - 0 ratings