将数据从 Corvid (node.js npm) 流式传输到 BigQuery - 请求缺少必需的身份验证凭据错误

Streaming data to BigQuery from Corvid (node.js npm) - Request is missing required authentication credential ERROR

我正在尝试使用 Corvid

将数据流式传输到我的 BigQuery table

所以我将 BigQuery 模型安装到节点。

mySecret 是令牌。

并在后端 bigquery.jsw 文件

上创建了这个函数
// 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 console JSON token,从 secret manager

获取

我从 Wix 页面调用了这个函数,但没有任何反应。

错误: 更新:将 {} 添加到 import BigQuery from '@google-cloud/bigquery';

现在错误不是构造器错误,而是 QAuth2 错误:

我把构造函数改成这样:

const bigquery = await new BigQuery({ projectId: projectId, keyFilename: path });

并修复了时间戳表达式
const 时间戳 = BigQuery.timestamp(new Date());