How to implement third party OAuth in Blazor App

Balu Raju 81 Reputation points

How to implement within Blazor server app a third-party OAuth. I know I can do that by creating a Razor View (.cstml) but I would like to see it done in razor component (.razor).

A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,496 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 61,266 Reputation points

    OAuth requires redirecting to the OAuth login site. After the user logins in the OAuth site it redirects back to the website reply-url passing a token. The reply-url then validates the token, creates a credential cookie, and redirects back to page that requested authentication. In your case the Blazor app hosting page which will load the app passing the credentials to the new Blazor app instance.

    You should be able to use the builtin OAuth support and just configure. The built in has no UI (in oauth mode) and just redirects to the OAuth server. There is also a Blazor component that handles redirecting to login/logout.

    note: as an OAuth login unload and reloads the Blazor app, you will need to save state if state must be passed from the pre-login to login mode.

    0 comments No comments