Skip to content

Blazor WASM Auth force token renew #39775

@johan-v-r

Description

@johan-v-r

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I'm trying to renew the user's access token without needing to refresh the page.

Describe the solution you'd like

I'd like to call a function on something like IAccessTokenProvider.RenewUserToken or RemoteAuthenticationService.RenewUserToken()

Additional context

Setup

I'm using the standard AddOidcAuthentication extension with my .AddHttpClient(...).AddHttpMessageHandler(sp => sp.GetRequiredService<AuthorizationMessageHandler>().ConfigureHandler(...)) on multiple HttpClient registrations.

Reason

Our JWT contains some dynamic data for multi-tenant use. So after certain user actions (i.e. switching tenants), they require a new JWT.

Attempts

Simply requesting a new JWT ourselves is insufficient as the other middleware needs to be notified of this.

Tried extending the RemoteAuthenticationService class to trigger NotifyAuthenticationStateChanged and various other functions, but seems like everything first checks for the (still valid) session token - so no renewal.

Couldn't see exactly what happens when the token expires, but it basically does what I want. Can that functionality be exposed somehow?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions