Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4175

Blazor restarts session when getting access token

$
0
0

I have a Blazor (SSR) app that makes a call to another service on behalf of the logged in user. To get the bearer token I call

await tokenAcquisition.GetAccessTokenForUserAsync(["api://<myappid>/user_impersonation"]);

But on the first time in a session the user does this I get a MicrosoftIdentityWebChallengeUserException with an InnerException that reads "No account or login hint was passed to the AcquireTokenSilent call." Calling ConsentHandler.HandleException(ex); on that exception fixes the issue without the user having to do anything, but it does cause a refresh which causes a new session to start. Subsequent calls work as expected.

I assume it's something to do with the token cache being empty, but is there a way to get a token with an appropriate scope at login rather than when the user clicks the button that makes the external call?

Would using .EnableTokenAcquisitionToCallDownstreamApi([scope]) work if I switched to the DownstreamApi rather than using Flurl to make the call? (DownstreamApi makes my brain hurt)


Viewing all articles
Browse latest Browse all 4175

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>