Open Closed

Refresh Token in Blazor Server App #5537


User avatar
0
neethucp created

Hi,

We are trying to implement a feature where in the user role is updated when the user accepts the terms and conditions after login. After the user accepts the terms and conditions, the user will have to see additional menu items. We already have refresh token enabled for the client application but is unsure on how to refresh the token from blazor server manually and store it so that the token is used in the subsequent requests. Can you please provide some guidance on how to refresh the token in blazor server app?

  • ABP Framework version: v7.3.1
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Serve)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

4 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can call the Challenge(new AuthenticationProperties { RedirectUri = your_returnUrl }, "oidc"); to get new access token.

    eg:

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs#L81

  • User Avatar
    0
    neethucp created

    Thank you so much for the response. We have a blazor server application, so we don't have access to httpcontext in razor components. So not sure on from where we have to invoke the Challenge method.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can add a controller or razor page to your blazor server project, and then redirect to its endpoint.

  • User Avatar
    0
    neethucp created

    That worked. Thank you so much.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 05, 2024, 12:19