`TokenCacheNotificationArgs.Account` is null when read from cache
See original GitHub issueI noticed that the first time the token is read from the cache it changes the HasTokens
but does not assign the Account to the TokenCacheNotificationArgs
in the OnAfterAccessAsync
method. Only after token is accessed with AcquireTokenInLongRunningProcess
is it set.
Which version of MSAL.NET are you using? 4.40.0
Platform ALL
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
Is this a new or existing app? a. The app is in production, and I have upgraded to a new version of MSAL.
Expected behavior
TokenCacheNotificationArgs.Account
should be set.
Actual behavior
TokenCacheNotificationArgs.Account
is null
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (4 by maintainers)
Top Results From Across the Web
`TokenCache.SerializeAdalV3` returns `null` even with a ...
Git Credential Manager wants to move to MSAL, and part of that means we need to be able to read and write to...
Read more >HttpContext.Current is null on TokenCache.BeforeAccess
I got it working. You have to pass the HttpContextBase for creating your session cache object. HttpContext. Current becomes null as it executes ......
Read more >TokenCacheNotificationArgs Class (Microsoft.Identity.Client)
It allows apps to unit test their MSAL token cache implementation code. Properties. Account. Gets the account involved in the cache transaction.
Read more >NullUserCache (Spring Security 4.0.4.RELEASE API)
getUsername() used to place the user in the cache; Returns: the populated UserDetails or null if the user could not be found or...
Read more >Azure AD v2 and MSAL from a developer's point of view
So for example, let's say we want to read the user's calendar events ... ClientSecret), userTokenCache, null); //Get access token (and Id ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the explanation, now it’s more clear! I did found a workaround for my problem so we can close this issue. Thanks everyone! 😃
@pmaytak - can you please comment on @gabrigiunchi 's objection?
AcquireTokenSilent
is aimed at web app scenario, not web api. It is scoped by the account itself, i.e. the user projection in a tenant (the user for short). Web API is session based, not user based.AcquireTokenSilent
isn’t to be used with web api. For backwards compat purposes, AcquireTokenSilent will never find a refresh token and will throw aUiRequiredException
error, which is part of the contract ofAcquireTokenSilent
.