Asp.net IdentityServer4谷歌签名回调不';t包括「;IdentityConstants.ExternalScheme“;曲奇

Asp.net IdentityServer4谷歌签名回调不';t包括「;IdentityConstants.ExternalScheme“;曲奇,asp.net,identityserver4,google-signin,Asp.net,Identityserver4,Google Signin,我有一个IdentityServer4身份提供程序服务器。在大多数情况下,我使用的是他们回购协议中的模板代码。我正在尝试添加谷歌登录。我在启动时配置了GoogleSignIn并添加了ClientId/ClientSecret 当我没有在GCP项目中配置返回URI时,我从Google得到以下错误: "The redirect URI in the request, https://localhost:44333/signin-google, does not match the ones

我有一个IdentityServer4身份提供程序服务器。在大多数情况下,我使用的是他们回购协议中的模板代码。我正在尝试添加谷歌登录。我在启动时配置了GoogleSignIn并添加了ClientId/ClientSecret

当我没有在GCP项目中配置返回URI时,我从Google得到以下错误:

"The redirect URI in the request, https://localhost:44333/signin-google, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs..."
当我添加URI时

然后,我一打电话给
Challenge
就立即收到了来自谷歌的失败回调

[HttpGet]
public async Task<IActionResult> Callback()
{
    var result = await HttpContext.AuthenticateAsync(IdentityConstants.ExternalScheme);
    // Here, result.Succeeded is false

    // Rest of the method...
}
[HttpGet]
公共异步任务回调()
{
var result=await HttpContext.authenticateSync(IdentityConstants.ExternalScheme);
//这里,result.successed为false
//方法的其余部分。。。
}


有什么问题吗?

如果您使用了
回调
方法,那么听起来Google auth已经成功完成了。但是,由于
IdentityConstants.ExternalScheme
cookie不存在,听起来您可能有点配置错误

一旦Google身份验证处理程序完成,它将使用其
signnscheme
属性中设置的身份验证方案或默认登录方案登录。它将来自谷歌的声明存储到本地身份验证方法中,如cookie


Google身份验证处理程序配置为使用什么方案?如果您使用的是QuickStart,它可能使用的是
IdentityServerConstants.ExternalCookieAuthenticationScheme
,而不是您正在寻找的ASP.NET Identity的
IdentityConstants.ExternalScheme

正是这样。将常量更改为
IdentityServerConstants。回调函数中的ExternalCookieAuthenticationScheme
解决了此问题。我应该用哪一个?由你决定。一个来自IdentityServer,另一个来自ASP.NET Identity。它们都是为同一件事设计的,并且配置了较短的生命周期。如果您使用的是ASP.NET Identity auth cookie,那么我想使用ASP.NET Identity外部cookie是一致的。