在.AddOpenIdConnect()
内部使用时ConfigureServices
,是否可以根据请求更改主机ClientId
并ClientSecret
基于主机?
我知道它Startup
本身无法访问HttpContext
,但我想知道是否使用中间件可以解决这个问题,它可以访问上下文.
我尝试过以下链接,但是在通过CustomAuthHandler ASP.NET Core 2.0身份验证中间件运行后,我的值始终为null
我目前正在尝试通过C#与Google Admin SDK集成,以便我们可以通过自己的系统管理用户。但是,在运行项目时出现错误:未经授权的客户端。
我已经通过超级管理员帐户完成的操作:
这是我正在使用的代码。
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(_googleServiceSettings.Client_Email)
{
ProjectId = _googleServiceSettings.Project_Id,
User = "superadmin@google.com",
Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser }
}.FromPrivateKey(_googleServiceSettings.Private_Key));
var service = new DirectoryService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "Test API"
});
var request = service.Users.Get("user@google.com");
var result = await request.ExecuteAsync();
Run Code Online (Sandbox Code Playgroud)
我得到的全部错误是
执行请求时发生未处理的异常。Google.Apis.Auth.OAuth2.Responses.TokenResponseException:错误:“ unauthorized_client”,说明:“客户端未经授权使用此方法检索访问令牌,或者客户端未获得所请求的任何范围的授权。”,Uri:“”
c# google-api google-api-dotnet-client google-admin-sdk gsuite
我在尝试之前尝试过搜索这个但是我发现每个结果都提到了GUID作为PK而不是这里的情况.
我有一个数据库,它使用INT作为所有表的PK.但是,数据是通过API调用访问的,并且要求不在任何API中返回或使用INT值.因此,我想在包含GUID的表上有一个额外的列.
现在我的问题是,如果我对GUID列进行索引会产生什么样的性能影响?它会是积极的还是消极的?请记住GUID不是PK或FK.