[英]How can I integrate a credential json file with GCP bigquery with nodejs?
I have a file type of json.我的文件类型为 json。 It is a credential file.
它是一个凭证文件。 I want to integrate with
GCP bigquery
and access to GCP bigquery
using this credential file with Nodejs.我想与
GCP bigquery
集成并使用此凭证文件和 Nodejs 访问GCP bigquery
。
How can I do that?我怎样才能做到这一点? How can integrate with
GCP bigquery
using credential file in nodejs?如何使用 nodejs 中的凭证文件与
GCP bigquery
集成? How can I test the result of integration to test integration is valid or not?如何测试集成结果以测试集成是否有效?
You probably want the keyFilename
attribute, unless I've misunderstood your question.您可能需要
keyFilename
属性,除非我误解了您的问题。
This GCP doc talks about authenticating using a service account key file. 此 GCP 文档讨论了使用服务帐户密钥文件进行身份验证。
So if your credentials file lived in /var/my_credentials.json
(dumb path but whatever), your Node.js code would look something like this:因此,如果您的凭据文件位于
/var/my_credentials.json
(无用路径,但无论如何),您的 Node.js 代码将如下所示:
const {BigQuery} = require('@google-cloud/bigquery');
const options = {
keyFilename: '/var/my_credentials.json',
projectId: 'my_project',
};
const bigquery = new BigQuery(options);
Also consider: keep the contents of that credentials file in Google Secret Manager and use gcloud secrets versions access latest
, dumping the output into a temporary json file local to the script, then remove the temporary json file after it's no longer needed by the script.还要考虑:将该凭证文件的内容保存在 Google Secret Manager 中并使用
gcloud secrets versions access latest
,将 output 转储到脚本本地的临时 json 文件中,然后删除临时 Z466DEEC76ECDF5FCA6D 脚本文件后不再需要的 Z466DEEC76ECDF5FCA6D38571F634 文件。 No need to have credentials floating around on servers.无需在服务器上浮动凭据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.