【发布时间】:2021-11-18 14:34:06
【问题描述】:
我需要访问一些 Google API(通过Google.Apis.* NuGet 包)。因此我需要使用Google.Apis.Auth.AspNetCore 包,如
official documentation:
services
.AddAuthentication(o =>
{
o.DefaultChallengeScheme = GoogleOpenIdConnectDefaults.AuthenticationScheme;
o.DefaultForbidScheme = GoogleOpenIdConnectDefaults.AuthenticationScheme;
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddGoogleOpenIdConnect(options =>
{
options.ClientId = googleClientId;
options.ClientSecret = googleClientSecret;
});
另一方面,我使用经典的 ASP.NET Core 标识,尤其是 Google external login setup
使用
Microsoft.AspNetCore.Authentication.Google NuGet 包初始化如下:
services
.AddAuthentication()
.AddGoogle(options =>
{
options.ClientId = googleClientId;
options.ClientSecret = googleClientSecret;
});
有没有办法共享 OAuth 配置、登录信息……? ???两个包都使用自己的 OAuth 初始化代码... ????我会遇到同时调用AddGoogle() 和AddGoogleOpenIdConnect() 的问题吗?
【问题讨论】:
标签: c# asp.net-core google-api google-oauth google-api-dotnet-client