Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using UseGoogleAuthentication

I am trying to build an application with google as the identity provider in asp.net core.

I used the bootstrap web application initialized by the dotnet cli tool:

dotnet new --type web

I added the Microsoft.AspNetCore.Authentication.Google nuget in my project.json.

I created a google application and a clientid/secret and added the google middle ware:

app.UseGoogleAuthentication(new GoogleOptions{
                ClientId = "<clientId>",
                ClientSecret = "<clientSecret>"
            });

But then, following the tutorial here, the following line should return a loginProvider collection with one element:

SignInManager.GetExternalAuthenticationSchemes()

But all I get is an empty IEnumerable. I tried to follow the source code but failed to find what I am doing wrong (bad client id configuration, missed something in Startup Configure(Service) functions).

How to get SignInManager.GetExternalAuthenticationSchemes() to return the google loginProvider?

like image 895
Simon Bergot Avatar asked Jul 24 '26 00:07

Simon Bergot


1 Answers

After some tests I figured it out. My mistake was to use UseGoogleAuthentication after UseMvc. Moving it just before fixes my issue.

I guess this posts explains it:

Developer Exception Page is blank if added to IApplicationBuilder after MVC

like image 151
Simon Bergot Avatar answered Jul 25 '26 14:07

Simon Bergot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!