【发布时间】:2020-06-23 22:42:12
【问题描述】:
我必须在我的 ASP.NET Core 应用程序中集成多个外部身份验证提供程序。
- Facebook 身份验证工作正常。
- 但 Google 身份验证遇到问题
var info = await signInManager.GetExternalLoginInfoAsync();
以上代码行在谷歌的情况下返回空值。但适用于 Facebook。
在Start.cs 中添加了 Google 身份验证,页面重定向到 Google 并返回到 ExternalLoginCallback 但无法从 cookie 中获取值:
services.AddAuthentication().AddGoogle(googleOptions =>
{
var config = Configuration.GetSection("GAuth").Get<AuthSetting>();
googleOptions.ClientId = config.ClientId;
googleOptions.ClientSecret = config.ClientSecret;
//googleOptions.UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/certs";
});
非常感谢您的帮助
【问题讨论】:
-
添加
googleOptions.UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";行后问题解决
标签: asp.net-core