question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blazor Delay in AccessToken being ready and authorized view showing

See original GitHub issue

Describe the bug

When making an HTTP call inside a component in the <Authorized> component the access token is not ready for a short time after login even when the authorized content renders. The call throws a exception however oddly enough the request still has a token attached.

blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: ''
Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessTokenNotAvailableException: ''
  at Microsoft.AspNetCore.Components.WebAssembly.Authentication.AuthorizationMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x32e45d0 + 0x0030e> in <filename unknown>:0 
  at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) <0x32cf170 + 0x0014c> in <filename unknown>:0 
  at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task`1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) <0x32e6f08 + 0x00134> in <filename unknown>:0 
  at System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsyncCore[T] (System.Threading.Tasks.Task`1[TResult] taskResponse, System.Text.Json.JsonSerializerOptions options, System.Threading.CancellationToken cancellationToken) <0x32f0800 + 0x000cc> in <filename unknown>:0 

To Reproduce

Make a HTTP with automatically attached access token as described in https://devblogs.microsoft.com/aspnet/blazor-webassembly-3-2-0-preview-5-release-now-available/ In the components oninit or after render method. results in Microsoft.AspNetCore.Components.WebAssembly.Authentication.AccessTokenNotAvailableException Refresh the page no more error.

Further technical details

  • ASP.NET Core version Blazor WASM rc1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
msftbot[bot]commented, Oct 9, 2020

We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

4reactions
reedptaylorcommented, May 27, 2020

Having the same issue in the GA version. Have only seen it happen on an iOS device, however.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor hosted - authorize immediately before displaying ...
Can anybody give me a helping push to get my hosted Blazor application (Client, Server and Shared) to request a login immediately, before...
Read more >
Is there sample for getting aadb2c Access Token for Blazor ...
Pass tokens to a Blazor Server app section is for AAD. Is there some reference on how to get azure ad b2c access...
Read more >
Blazor WebAssembly standalone - Authentication and ...
IDS4 is a certified OpenId provider library. For authentication I am using Authorization Code flow on OpenID Connect. Bellow diagram is to show...
Read more >
Blazor Login Expiration with OpenID Connect
If your login token is still valid (it hasn't expired), but your cookie has expired, you'll be logged out of the client. On...
Read more >
Authentication - JamesYeung/blazor-workshop
This message handler will acquire access tokens using the built-in IAccessTokenProvider service and attach them to each request using the standard Authorization ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found