Aspnetcore: [Blazor] Documentation for OAuth flow with client-side Blazor

Created on 18 Jul 2019  路  3Comments  路  Source: dotnet/aspnetcore

I am trying to do setup a client-side Blazor (ASP.NET Core Hosted) project with a third-party OAuth2 login provider, but the current documentation for authentication and authrorization doesn't cover this use-case.

The scenario requires me to only use the third-party login provider, without any other identity source.

The current MVC approach involves a challenge call that redirects to the third-party provider and returns the token. This approach doesn't seem to work with Blazor. Therefore, additional documentation would be helpful.

Docs area-blazor blazor-wasm

Most helpful comment

You can make it work with Blazor :

  • you have to redirect your user to the MVC action and he'll be challenged to the third party provider.
  • the redirection url will be a MVC action that will save the user if new and redirect to account creation page or redirect to home page if existing (nearly the same as the template's)
  • Then you have to create a Blazor page for creating an account for this user and posting the information to an other mvc action

https://remibou.github.io/Google-OAuth-with-Blazor-ASPNET-Core-Week-26/

All 3 comments

You can make it work with Blazor :

  • you have to redirect your user to the MVC action and he'll be challenged to the third party provider.
  • the redirection url will be a MVC action that will save the user if new and redirect to account creation page or redirect to home page if existing (nearly the same as the template's)
  • Then you have to create a Blazor page for creating an account for this user and posting the information to an other mvc action

https://remibou.github.io/Google-OAuth-with-Blazor-ASPNET-Core-Week-26/

Thank you @RemiBou - this is a very helpful resource. Even though a little bit "old" by now, a new version should make it into the docs.

I just found out, however, that external providers will fail on the callback from the provider, documented here: https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers/issues/324

Closing this issue in favor of the other issue tracking docs support for the new authentication options we've added. https://github.com/dotnet/aspnetcore/issues/19283

Was this page helpful?
0 / 5 - 0 ratings