使用 JSON 进行 GBQ 身份验证

发布于 2025-01-14 00:33:45 字数 485 浏览 5 评论 0原文

我正在检索 GBQ service_account 的凭据以进行身份​​验证和使用 GBQ。凭证带有 private_key、c​​lient_id、token_uri、project_id 和一些其他信息。我正在尝试创建一个像这样的客户端

const gbqCredentials = decodeKey(credentials),
bigQuery = new BigQuery(JSON.parse(gbqCredentials.toString()));

但是我得到了下一个异常: {"message":"错误:无法加载默认凭据。浏览到 https:/ /cloud.google.com/docs/authentication/getting-started 了解更多信息.."}

I am retrieving the credentials for a GBQ service_account to authenticate and use GBQ. The credentials come with a private_key, client_id, token_uri, project_id and some other information. I am trying to create a client like this

const gbqCredentials = decodeKey(credentials),
bigQuery = new BigQuery(JSON.parse(gbqCredentials.toString()));

But i get th next exception:
{"message":"Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.."}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

打小就很酷 2025-01-21 00:33:45

为了解决这个问题,我通过 JSON 传递了凭据并添加了参数 projectId(我之前没有添加)。

decodedCredentials = decodeKey(credentials);
const gbqCredentials = JSON.parse(decodedCredentials.toString());
bigQueryInstance = new BigQuery({credentials: gbqCredentials, projectId: `projectId`});

To solve the issue I passed the credentials on a JSON and added a parameter projectId (Which I didn't add before).

decodedCredentials = decodeKey(credentials);
const gbqCredentials = JSON.parse(decodedCredentials.toString());
bigQueryInstance = new BigQuery({credentials: gbqCredentials, projectId: `projectId`});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文