Google cloud platform 从Corvid(node.js npm)将数据流式传输到BigQuery-请求缺少必需的身份验证凭据错误
我正在尝试使用Corvid将数据流传输到我的BigQuery表 所以我将BigQuery模型安装到节点。 我的秘密就是象征 并在后端bigquery.jsw文件上创建了此函数Google cloud platform 从Corvid(node.js npm)将数据流式传输到BigQuery-请求缺少必需的身份验证凭据错误,google-cloud-platform,google-bigquery,google-oauth,velo,Google Cloud Platform,Google Bigquery,Google Oauth,Velo,我正在尝试使用Corvid将数据流传输到我的BigQuery表 所以我将BigQuery模型安装到节点。 我的秘密就是象征 并在后端bigquery.jsw文件上创建了此函数 // Imports the Google Cloud client library import {BigQuery} from '@google-cloud/bigquery'; import _ from 'lodash'; import {getSecret} from 'wix-secrets-backend'
// Imports the Google Cloud client library
import {BigQuery} from '@google-cloud/bigquery';
import _ from 'lodash';
import {getSecret} from 'wix-secrets-backend';
//...
//POST https://bigquery.googleapis.com/bigquery/v2/projects/{projectId}/datasets/{datasetId}/tables/{tableId}/insertAll
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';
const datasetId = 'wix_data';
const tableId = 'user_data';
const projectId = 'XXXXholder-XXXX'
const current_timestamp = new Date().getTime()
export async function insertRowsAsStream() {
const mySecret = await getSecret("google_cloud_api");
const bigquery = new BigQuery({ projectId, mySecret });
// Inserts the JSON objects into my_dataset:my_table.
/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
const rows = [
{timestamp: current_timestamp, token: 'test'},
// {name: 'Jane', age: 32},
];
// Insert data into a table
return await bigquery
.dataset(datasetId)
.table(tableId)
.insert(rows);
}
//main(...process.argv.slice(2));
*getSecret是google控制台JSON令牌,从secret manager获取
我从Wix页面调用了这个函数,但什么也没发生。
错误:
更新:将{}添加到从'@googlecloud/BigQuery'导入BigQuery'
现在的错误不是constructor错误,而是QAuth2 erorrs:
我把承包商改成这样:
const bigquery = await new BigQuery({ projectId: projectId, keyFilename: path });
并修复了时间戳表达式constamptimestamp=BigQuery.timestamp(newdate())