Simon Bergot
Simon Bergot

Reputation: 10592

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?

Upvotes: 3

Views: 1851

Answers (1)

Simon Bergot
Simon Bergot

Reputation: 10592

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

Upvotes: 3

Related Questions