大查询 - 来自部署在GKE中的nodejs应用程序的Util.parseHttpRespBody中的凭证无效

问题描述 投票:0回答:1

我有一个节点js应用程序,它公开可通过云端点访问的其他端点。在触发端点url时,节点js执行大查询并返回结果。一切正常,我将它部署在计算引擎中。由于我使用的是大查询数据集可用的相同服务帐户,因此我不添加“service-account-key.json”文件。仅明确提及将执行查询的数据集的位置,即“EU”。

但是在GKE中部署之后,我遇到了以下错误,仅针对那些正在访问Big Query的端点。错误是:

我在尝试之前已经启用了大查询apis,正如我所提到的,它在计算机引擎作为一个样本开发平台之前工作,然后才能容纳它。

ERROR: ApiError: Invalid credential at Util.parseHttpRespBody (/app/node_modules/@google-cloud/common/build/src/util.js:190:38) at Util.handleResp (/app/node_modules/@google-cloud/common/build/src/util.js:134:117) at /app/node_modules/@google-cloud/common/build/src/util.js:422:22 at onResponse (/app/node_modules/retry-request/index.js:200:7) at /app/node_modules/teeny-request/build/src/index.js:222:13 at processTicksAndRejections (internal/process/task_queues.js:88:5) {

下一行堆栈驱动程序:

 severity:  "ERROR"  
 textPayload:  "      domain: 'global',

locationType: 'other',

感谢您的宝贵意见。

此致,阿林达姆

node.js google-bigquery google-kubernetes-engine
1个回答
4
投票

由于我使用的是大查询数据集可用的相同服务帐户,因此我不添加“service-account-key.json”文件。

您的问题是您必须提供服务帐户文件密钥下面找到一个工作node.js Mocha测试示例,它访问BigQuery并执行选择。

if (!global._babelPolyfill) {
    var a = require("babel-polyfill")
}

    import BigQuery from '@google-cloud/bigquery'

    describe('Check google-cloud', async () => {

        it('Test query', async () => {
            let result = await test('panada')

        })

        async function test(p1) {
            try {
                const bigquery = new BigQuery({
                    projectId: `mydata`,
                    keyFilename: 'mydata-1470162410749-9473b308ab0e.json'
                })

                let query = [
                    'SELECT url',
                    'FROM `publicdata.samples.github_nested`',
                    'WHERE repository.owner = @owner'

                ].join(' ')

                console.log(`query is: ${query}`)
                let [result] = await bigquery.query({
                    query,
                    params: {
                        owner: p1
                    }
                })

                result.forEach((row, index) => {
                    console.log(`row number ${index}, url is: ${row.url}`)
                })
            } catch (err) {
                console.log("err", err)
            }
        }
    })

此代码的输出是:

row number 0, url is: https://github.com/panada/samples/compare/46934664ea...a7cae9f088
    row number 1, url is: https://github.com/panada/Panada/compare/47a1801f13...9dedbc8ce6
    row number 2, url is: https://github.com/panada/samples/compare/a7cae9f088...256c9b4ed3
    row number 3, url is: https://github.com/panada/Panada/pull/36
    row number 4, url is: https://github.com/de3/Panada
    row number 5, url is: https://github.com/schbern/samples
    row number 6, url is: https://github.com/panada/Panada/compare/175c88e2cb...47a1801f13
    row number 7, url is: https://github.com/panada/samples/compare/256c9b4ed3...1f293ca245
    row number 8, url is: https://github.com/panada/documentation/compare/49c38b23e2...d948d2eb97
    row number 9, url is: https://github.com/panada/Panada/pull/38
    row number 10, url is: https://github.com/panada/samples/compare/1a35a44548...46934664ea
    row number 11, url is: https://github.com/de3/documentation
    row number 12, url is: https://github.com/cakyus/Panada
    row number 13, url is: https://github.com/panada/documentation/compare/46b7bcde5f...52e9ef5c67
    row number 14, url is: https://github.com/panada/documentation/issues/1#issuecomment-4533276
    row number 15, url is: https://github.com/panada/documentation/compare/d948d2eb97...46b7bcde5f
    row number 16, url is: https://github.com/panada/Panada/compare/9dedbc8ce6...4db3e50d80
    row number 17, url is: https://github.com/panada/Panada/pull/38
    row number 18, url is: https://github.com/panada/documentation/pull/1
    row number 19, url is: https://github.com/panada/documentation/pull/1
© www.soinside.com 2019 - 2024. All rights reserved.