I have a node js application that exposes rest endpoints that is accessible via cloud endpoint. While firing the endpoint url, node js executes big query and returns results. Everything is working fine I deployed it in compute engine. Since I am using same service account where big query datasets are available, so I am not adding "service-account-key.json" file. Only explicitely mentioning Location of the dataset where the query will be executed i.e. 'EU'.
But after the deployment in GKE I have got following errors, only for those end points whichs are accessing Big Query. Error is:
I have enabled big query apis before trying it, as I have mentioned it works from compute engine as a sample development platform before containerizing it.
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) {
next line of stack driver:
severity: "ERROR"
textPayload: " domain: 'global',
and
locationType: 'other',
Thanks for your valuable feedback.
Regards, Arindam
Since I am using same service account where big query datasets are available, so I am not adding "service-account-key.json" file.
Your problem is that you MUST provide the service account file key Below find a working node.js Mocha test example which accesses BigQuery and performs a select.
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)
}
}
})
The output of this code is:
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