首页 > 解决方案 > 谷歌 G-Suite / Workspace SDK

问题描述

我正在使用一套 Google.Apis NuGet 打包 SDK(例如 Google.Apis、Google.Apis.Auth、Google.Apis.Core),并且我发现了一些用于身份验证的可选参数。不是下面的“可选”评论......

initializer = new BaseClientService.Initializer
{
    HttpClientInitializer = new ServiceAccountCredential(
        new ServiceAccountCredential.Initializer(creds.ClientEmail)
        {
            User = creds.AdminEmail,
            Scopes = new[] { DirectoryService.Scope.AdminDirectoryUserReadonly },
            Key = RSA.Create(creds.PrivateKey),

            // ***THIS IS OPTIONAL***
            KeyId = creds.PrivateKeyId,

            // ***THIS IS OPTIONAL***
            ProjectId = creds.ProjectID
        }.FromPrivateKey(creds.PrivateKey))
};

上述两个“可选”值均由 Google 网络管理界面提供,但在身份验证期间是否使用它们是我的选择。我没有找到任何解释它们代表什么以及为什么它们是可选的文档。如果我提供它们,我会得到什么或失去什么?如果我省略它们?

我可以隐约猜到这ProjectID有一些与身份验证相关的审计跟踪目的。但另一个,我只是不知道。

帮助?

标签: c#authenticationgoogle-apigoogle-workspace

解决方案


推荐阅读