You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The acquireTokenSilent method, used to fetch access tokens (including the ability to refresh tokens when needed) from the MSAL SDK is not performant enough for it's use case.
In our practical use of the MSAL library, we use an OkHttpInterceptor to append tokens to each request. These tokens are pulled from MSAL using acquireTokenSilent. Based on the documentation, this should mean on most requests that the access tokens are pulled from a cache and returned, except in the case where there is no valid access token. This works, but the time to fetch a token from the MSAL using this method is not performant - on the order of hundreds of milliseconds. When caching the access token locally instead we're able to fetch new tokens in less than 100ms.
Smartphone
Observed on multiple combinations of Android devices, operating systems, and browsers. com.microsoft.identity.client:msal version 4.0.1.
Stacktrace
N/A
To Reproduce
Steps to reproduce the behavior:
Follow vanilla setup for MSAL Android project
Use acquireTokenSilent to fetch tokens on every network call
Make network calls as normal, and log the duration of each acquireTokenSilent call
Expected behavior
When access token is valid, calls to acquireTokenSilent should return tokens almost instantaneously.
Actual Behavior
When access token is valid, calls to acquireTokenSilent are returning tokens in between 100-1000ms.
Screenshots
Timing the time it takes to get a token from MSAL vs. pulling it from our local cache.
Yes, we use acquireTokenSilent to fetch an access token on every request. Our app does heavily rely on network calls and we often make them in bunches (like during app startup).
Happening across devices & emulators, but I'm testing on a Google Pixel 4a on Android 13.
Yes, I'll run a test on the latest version and see if I see any performance improvements and report back.
Describe the bug
The
acquireTokenSilent
method, used to fetch access tokens (including the ability to refresh tokens when needed) from the MSAL SDK is not performant enough for it's use case.In our practical use of the MSAL library, we use an
OkHttp
Interceptor
to append tokens to each request. These tokens are pulled from MSAL usingacquireTokenSilent
. Based on the documentation, this should mean on most requests that the access tokens are pulled from a cache and returned, except in the case where there is no valid access token. This works, but the time to fetch a token from the MSAL using this method is not performant - on the order of hundreds of milliseconds. When caching the access token locally instead we're able to fetch new tokens in less than 100ms.Smartphone
Observed on multiple combinations of Android devices, operating systems, and browsers.
com.microsoft.identity.client:msal
version4.0.1
.Stacktrace
N/A
To Reproduce
Steps to reproduce the behavior:
acquireTokenSilent
to fetch tokens on every network callacquireTokenSilent
callExpected behavior
When access token is valid, calls to
acquireTokenSilent
should return tokens almost instantaneously.Actual Behavior
When access token is valid, calls to
acquireTokenSilent
are returning tokens in between 100-1000ms.Screenshots
Timing the time it takes to get a token from MSAL vs. pulling it from our local cache.
Additional context
Related SO Post summarizing the same issue.
The text was updated successfully, but these errors were encountered: