使用Google OWIN提供程序时,GetExternalLoginInfo返回“null”

5
我有一个来自Visual Studio 2013的几乎标准的ASP.NET MVC模板应用程序。它是使用以下设置创建的:

创建 > 项目 > Web > ASP.NET Web应用程序 > 确定 > MVC,单个用户帐户 > 确定

我正在尝试使用OWIN Google提供程序进行登录,并遇到问题。
OWIN的Configuration方法如下:
        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);

我在网页上点击了Google提供商按钮,使用谷歌进行身份验证,然后被引导回到ExternalLoginCallback页面。在这一点上,该过程在以下行中停止:

var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();

loginInfo为空,这将使我被重定向回登录页面,而没有任何可见的错误。

1个回答

5
我在这里回答一个旧问题,但对于未来可能遇到此问题的任何人,我找到的解决方法是使用Google Developers Console中的API Manager启用“Google+ API”。

这对我有用,我只需要等大约5分钟让谷歌应用更改或类似的东西...谢谢! - Davide Icardi
这对我有用,真奇怪所有其他的解决方法都不起作用...谢谢PaulPerkins。 - fmourtaza

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接