3

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?

2
  • Strange, it has nothing to do with Ids, it won't validate even if we put some value there. You're using the same code as generated by dotnet new right? I did the same and working without any issue Commented Jul 5, 2016 at 0:49
  • Thanks. I finally figured it out. See my answers. Commented Jul 10, 2016 at 12:18

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

I thought this issue was a systemic bug in Core when testing VS2017 RC2! What a simple solution. I moved my app.UseFacebookAuthentication(... middleware code above my app.UseMvc(routes =>... code and it works perfectly, Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.