在 C# 应用程序中使用 JSON 文件的 Google BigQuery 服务帐户凭据

2024-01-01

在为 Google BigQuery 创建服务帐户时,有两种关键文件类型。 1. P12 密钥文件 2. JSON 密钥文件。

我可以使用以下代码使用 P12 密钥文件将 Google BigQuery 与服务帐户凭据连接起来。

字符串服务帐户电子邮件=“[电子邮件受保护] /cdn-cgi/l/email-protection";

            var certificate = new X509Certificate2(@"FileName.p12", "Secret Key", X509KeyStorageFlags.Exportable);

            ServiceAccountCredential credential = new ServiceAccountCredential(
               new ServiceAccountCredential.Initializer(serviceAccountEmail)
               {
                   Scopes = new[] { BigqueryService.Scope.Bigquery, BigqueryService.Scope.BigqueryInsertdata, BigqueryService.Scope.CloudPlatform, BigqueryService.Scope.DevstorageFullControl }
               }.FromCertificate(certificate));

            BigqueryService Service = new BigqueryService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "PROJECT NAME"
            });

现在我尝试使用 JSON 文件类型连接服务帐户凭据,但我无法获得正确的创建语法。

我们如何使用 JSON 文件将 Google BigQuery 与服务帐户凭证连接起来?

Thanks,


我得到了链接,这表明Google BigQuery API 中尚未添加在 C# 应用程序中使用 JSON 文件进行服务帐户身份验证,所以我想结束这个问题。

https://github.com/google/google-api-dotnet-client/issues/533 https://github.com/google/google-api-dotnet-client/issues/533

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 C# 应用程序中使用 JSON 文件的 Google BigQuery 服务帐户凭据 的相关文章

随机推荐