GetExternalLoginInfo returns "null" in Google OWIN provider

I have an ASP.NET MVC limited stock application from Visual Studio 2013. It was created using the following settings:

Create> Project> Web> ASP.NET Web Application> OK> MVC, Individual User Accounts> OK

I am trying to log in using the Google OWIN provider and the problem.

The OWINs Configuration method is as follows:

  app.UseCookieAuthentication(new CookieAuthenticationOptions { AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie, LoginPath = new PathString("/Account/Login") }); app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie); var google = new Microsoft.Owin.Security.Google.GoogleOAuth2AuthenticationOptions { ClientId = "xxxxx.apps.googleusercontent.com", ClientSecret = "xxxxxxxxx-yyyyyyyyy" }; google.Scope.Add("profile"); google.Scope.Add("email"); app.UseGoogleAuthentication(google); 

I click the Google provider button on the webpage, authenticate with google, go back to ExternalLoginCallback . At this stage, the process is broken into this line:

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync ();

loginInfo is null , which redirects me back to the login page without visible errors.

+5
source share
1 answer

I am answering an old question here, but for those who might run into this problem in the future, the solution that worked for me is to enable the β€œGoogle+ API” using the API manager from the Google Developer Console.

+4
source

Source: https://habr.com/ru/post/1211836/


All Articles