2016-11-11 37 views
0

我知道我错过了一些明显的东西,但我无法弄清楚它是什么。我正在尝试做一个简单的“使用Google登录”测试应用程序,在获得Google同意屏幕后,我的网站上会显示403。ASP.NET Core Google登录退货403

在启动时,我配置的cookie和谷歌:

app.UseCookieAuthentication(new CookieAuthenticationOptions 
{ 
    AuthenticationScheme = "Cookies", 
    AutomaticAuthenticate = true, 
    AutomaticChallenge = true, 
    LoginPath = new Microsoft.AspNetCore.Http.PathString("/Account/Login"), 
    AccessDeniedPath = new Microsoft.AspNetCore.Http.PathString("/Account/Denied") 
}); 

app.UseGoogleAuthentication(new GoogleOptions 
{ 
    AuthenticationScheme = "Google", 
    SignInScheme = "Cookies", 
    ClientId = "xxx"                  
    ClientSecret = "xxx"                 
    AutomaticChallenge = true 
}); 

我已经配置了谷歌API打端点中间件创建:

enter image description here

但是从谷歌回调http://localhost:5000/signin-google?state=xxxxxxx给我一个403错误。我的开发人员异常页面显示:

enter image description here

我的登录方法很简单:

[HttpGet("login")] 
public IActionResult Login(string returnUrl) 
{ 
    return Challenge(new AuthenticationProperties 
    { 
     RedirectUri = returnUrl ?? "Home/Index" 
    }); 
} 

有人可以帮助我与我的硬伤理解?

回答

1

Gah。我知道了。原来我的应用配置正确。我不得不“启用”在谷歌的控制台API了Google+ API:

enter image description here

如果有人知道这背后的原因,或者为什么它不是很明显,你需要做到这一点,我当然喜欢知道。