【问题标题】:.net core 2.1 MVC - External Authentication for google not working.net core 2.1 MVC - 谷歌的外部身份验证不起作用
【发布时间】: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


【解决方案1】:

在 startup.cs 类中添加以下行后问题已解决

googleOptions.UserInformationEndpoint = "https://www.googleapis.com/oauth2/v2/userinfo";```

【讨论】:

    猜你喜欢
    • 2015-04-20
    • 2021-01-04
    • 1970-01-01
    • 2020-11-05
    • 2015-12-12
    • 1970-01-01
    • 2019-02-09
    • 1970-01-01
    • 2017-12-19
    相关资源
    最近更新 更多