Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GetExternalLoginInfo returns 'null' on Google OWIN provider

I've got a nearly stock ASP.NET MVC template 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'm attempting to log in using the OWIN Google provider and having issues.

OWINs Configuration method looks like this:

        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 web page, authenticate with google, get referred back to ExternalLoginCallback. At this point, the process breaks down at this line:

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

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

like image 667
Jesse Hallam Avatar asked Jan 24 '15 17:01

Jesse Hallam


1 Answers

I'm responding to an old question here, but for anyone in the future who may encounter this problem, the solution that worked for me was to enable the "Google+ API" using the API Manager from the Google Developers Console.

like image 188
PaulPerkins Avatar answered Nov 02 '22 13:11

PaulPerkins