[Bug] AcquireTokenSilent gets refreshed every time because NoCachedAccessToken
See original GitHub issueLogs and network traces
2022-09-23 15:33:11.407059-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - 8b26adb7-2b1e-4f0e-8c7d-036c73a9a5f8] [GetAccounts] Found 1 RTs and 1 accounts in MSAL cache. ]
2022-09-23 15:33:11.408925-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - 8b26adb7-2b1e-4f0e-8c7d-036c73a9a5f8] Skipping Instance discovery for B2C authority]
2022-09-23 15:33:11.409561-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - 8b26adb7-2b1e-4f0e-8c7d-036c73a9a5f8] [Instance Discovery] Skipping Instance discovery for non-AAD authority. ]
2022-09-23 15:33:11.410519-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - 8b26adb7-2b1e-4f0e-8c7d-036c73a9a5f8] [GetAccounts] Found 1 RTs and 1 accounts in MSAL cache after environment filtering. ]
2022-09-23 15:33:11.413625-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z] Found 1 cache accounts and 0 broker accounts]
2022-09-23 15:33:11.414274-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z] Returning 1 accounts]
2022-09-23 15:33:11.416531-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] MSAL MSAL.Xamarin.iOS with assembly version '4.47.0.0'. CorrelationId(bf595078-05ea-456d-b935-b7b86f9e9c98)]
2022-09-23 15:33:11.418084-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] === AcquireTokenSilent Parameters ===]
2022-09-23 15:33:11.418325-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] LoginHint provided: False]
2022-09-23 15:33:11.418653-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Account provided: True]
2022-09-23 15:33:11.418912-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] ForceRefresh: False]
2022-09-23 15:33:11.421525-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98]
=== Request Data ===
Authority Provided? - True
Scopes -
Extra Query Params Keys (space separated) -
2022-09-23 15:33:11.421811-0400 TeamApp[82374:2025203] ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - bf595078-05ea-456d-b935-b7b86f9e9c98
UserAssertion set: False
LongRunningOboCacheKey set: False
2022-09-23 15:33:11.421992-0400 TeamApp[82374:2025203] Region configured:
]
2022-09-23 15:33:11.422517-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] === Token Acquisition (SilentRequest) started:
Scopes: ]
2022-09-23 15:33:11.424163-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Attempting to acquire token using using local cache...]
2022-09-23 15:33:11.428643-0400 TeamApp[82374:2025203] MSAL log [LogAlways] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [FindAccessTokenAsync] Discovered 0 access tokens in cache using partition key: 327dfd62-fd1e-418e-8ea3-0d752262f7f8-b2c_1_signup_signin.6a628427-9204-41f3-8c7f-4d50c48ab3d5]
2022-09-23 15:33:11.428904-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [FindAccessTokenAsync] No access tokens found in the cache. Skipping filtering. ]
2022-09-23 15:33:11.434172-0400 TeamApp[82374:2025203] MSAL log [LogAlways] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [FindRefreshTokenAsync] Discovered 1 refresh tokens in cache using key: 327dfd62-fd1e-418e-8ea3-0d752262f7f8-b2c_1_signup_signin.6a628427-9204-41f3-8c7f-4d50c48ab3d5]
2022-09-23 15:33:11.434997-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Filtering RT by home account id - item count before: 1 ]
2022-09-23 15:33:11.435598-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Filtering RT by home account id - item count after: 1 ]
2022-09-23 15:33:11.435905-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Filtering RT by family id - item count before: 1 ]
2022-09-23 15:33:11.436279-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Filtering RT by family id - item count after: 1 ]
2022-09-23 15:33:11.436547-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Filtering RT by client id - item count before: 1 ]
2022-09-23 15:33:11.436925-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Filtering RT by client id - item count after: 1 ]
2022-09-23 15:33:11.437286-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Skipping Instance discovery for B2C authority]
2022-09-23 15:33:11.437563-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [Instance Discovery] Skipping Instance discovery for non-AAD authority. ]
2022-09-23 15:33:11.437931-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [FindRefreshTokenAsync] Refresh token found in the cache? - True]
2022-09-23 15:33:11.439523-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Refreshing access token...]
2022-09-23 15:33:11.440136-0400 TeamApp[82374:2025203] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [Instance Discovery] Skipping Instance discovery for non-AAD authority. ]
2022-09-23 15:33:11.446117-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Starting TokenClient:SendTokenRequestAsync]
2022-09-23 15:33:11.452739-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [Token Client] Fetching MsalTokenResponse .... ]
2022-09-23 15:33:11.454999-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Starting [Oauth2Client] Sending POST request ]
2022-09-23 15:33:11.472143-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Starting [HttpManager] ExecuteAsync]
2022-09-23 15:33:11.475309-0400 TeamApp[82374:2025203] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:11Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [HttpManager] Sending request. Method: POST. Host: https://usssab2c.b2clogin.com. ]
2022-09-23 15:33:21.006023-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [HttpManager] Received response. Status code: OK. ]
2022-09-23 15:33:21.015800-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Finished [HttpManager] ExecuteAsync in 9543 ms]
2022-09-23 15:33:21.016444-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Finished [Oauth2Client] Sending POST request in 9561 ms]
2022-09-23 15:33:21.021366-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Starting [OAuth2Client] Deserializing response]
2022-09-23 15:33:21.101054-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Finished [OAuth2Client] Deserializing response in 79 ms]
2022-09-23 15:33:21.102126-0400 TeamApp[82374:2025418] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] ScopeSet was missing from the token response, so using developer provided scopes in the result. ]
2022-09-23 15:33:21.102503-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Finished TokenClient:SendTokenRequestAsync in 9656 ms]
2022-09-23 15:33:21.103935-0400 TeamApp[82374:2025418] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Checking client info returned from the server..]
2022-09-23 15:33:21.108628-0400 TeamApp[82374:2025418] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Saving token response to cache..]
2022-09-23 15:33:21.111737-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98]
[MsalTokenResponse]
ErrorDescription:
Scopes:
ExpiresIn: 0
RefreshIn:
AccessToken returned: False
2022-09-23 15:33:21.111912-0400 TeamApp[82374:2025418] AccessToken Type: Bearer
RefreshToken returned: True
IdToken returned: True
ClientInfo returned: True
FamilyId:
WamAccountId exists: False
]
2022-09-23 15:33:21.130224-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [SaveTokenResponseAsync] Entering token cache semaphore. Count Real semaphore: True. Count: 1.]
2022-09-23 15:33:21.130884-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [SaveTokenResponseAsync] Entered token cache semaphore. ]
2022-09-23 15:33:21.131134-0400 TeamApp[82374:2025418] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [SaveTokenResponseAsync] Saving Id Token and Account in cache ...]
2022-09-23 15:33:21.147265-0400 TeamApp[82374:2025418] MSAL log [Informational] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [SaveTokenResponseAsync] Saving RT in cache...]
2022-09-23 15:33:21.152529-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] Not saving to ADAL legacy cache. ]
2022-09-23 15:33:21.153095-0400 TeamApp[82374:2025418] MSAL log [Verbose] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] [SaveTokenResponseAsync] Released token cache semaphore. ]
2022-09-23 15:33:21.155531-0400 TeamApp[82374:2025418] MSAL log [LogAlways] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98]
[LogMetricsFromAuthResult] Cache Refresh Reason: NoCachedAccessToken
2022-09-23 15:33:21.155709-0400 TeamApp[82374:2025418] [LogMetricsFromAuthResult] DurationInCacheInMs: 0
[LogMetricsFromAuthResult] DurationTotalInMs: 9735
[LogMetricsFromAuthResult] DurationInHttpInMs: 9529
]
2022-09-23 15:33:21.155957-0400 TeamApp[82374:2025418] MSAL log [LogAlways] [False MSAL 4.47.0.0 MSAL.Xamarin.iOS .NET 6.0.9 15.0 [2022-09-23 19:33:21Z - bf595078-05ea-456d-b935-b7b86f9e9c98] TokenEndpoint: ****]
Which version of MSAL.NET are you using? 4.47.0
Platform net6.0-ios
What authentication flow has the issue?
- Desktop / Mobile
- Interactive
- Integrated Windows Authentication
- Username Password
- Device code flow (browserless)
- Web app
- Authorization code
- On-Behalf-Of
- Daemon app
- Service to Service calls
Other?
Is this a new or existing app?
New app
Repro
_pca.AcquireTokenSilent(Constants.Scopes, account)
Expected behavior Cached token is loaded without a need to hit the network
Actual behavior
NoCachedAccessToken
is thrown, and then the token is successfully refreshed using the cached RefreshToken
Possible solution
Additional context / logs / screenshots / links to code I’m not sure if this is a config issue, a docs issue, or something else… but I would have expected there to be no need to refresh my cached JWT if it wasn’t expired. However, 100% of the time, the silent flow refreshes which means I need to manually handle starting without network connectivity by using a separately/manually cached token.
Issue Analytics
- State:
- Created a year ago
- Comments:16 (8 by maintainers)
Top GitHub Comments
Do you mind sharing your appsettings.json, @J-Swift ?
The relevant appsettings