[英]ASP.NET Core Google Sign In Returns 403
I know I am missing something obvious, but I cannot figure out what it is. 我知道我缺少明显的东西,但是我无法弄清楚它是什么。 I'm trying to make a simple 'Login with Google' test app, and after I get the google consent screen, it follows with a 403 on my site.
我正在尝试制作一个简单的“使用Google登录”测试应用,当我获得Google同意屏幕后,在我的网站上显示403。
In Startup, I configure cookie and google: 在启动中,我配置Cookie和Google:
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
});
I've configured the google api to hit the endpoint the middleware creates: 我已经将google api配置为击中中间件创建的端点:
but the callback from google to http://localhost:5000/signin-google?state=xxxxxxx
gives me a 403 error. 但是从Google到
http://localhost:5000/signin-google?state=xxxxxxx
的回调给了我403错误。 My developer exceptions page shows: 我的开发人员例外页面显示:
My login method is simply: 我的登录方法很简单:
[HttpGet("login")]
public IActionResult Login(string returnUrl)
{
return Challenge(new AuthenticationProperties
{
RedirectUri = returnUrl ?? "Home/Index"
});
}
Can someone help me with my flawed understanding? 有人可以帮助我了解我的错误吗?
Gah. 加。 I got it.
我知道了。 Turns out my app was configured correctly.
原来我的应用程序配置正确。 I had to 'Enable' the Google+ API in google's console API:
我必须在Google的控制台API中“启用” Google+ API:
If someone knows the reasoning behind this, or why it's not very obvious that you need to do this, I'd certainly like to know. 如果有人知道这背后的原因,或者为什么不是很明显您需要这样做,那么我当然想知道。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.