Code breaking while authenticating
I am connecting to big query using JWT client. My application is high scale and makes this connection every time it wants to stream data into big query.
Any possible fix to this?
Raw error log;
crypto.js:398
var ret = this._binding.sign(toBuf(key));
^
TypeError: Not a buffer
at Sign.sign (crypto.js:398:27)
at createRS256Signature (/home/ubuntu/vikram/test/shock/node_modules/googleapis/node_modules/gapitoken/node_modules/jws/index.js:75:58)
at jwsRS256Sign (/home/ubuntu/vikram/test/shock/node_modules/googleapis/node_modules/gapitoken/node_modules/jws/index.js:68:21)
at Object.jwsSign [as sign] (/home/ubuntu/vikram/test/shock/node_modules/googleapis/node_modules/gapitoken/node_modules/jws/index.js:32:12)
at GAPI.getAccessToken (/home/ubuntu/vikram/test/shock/node_modules/googleapis/node_modules/gapitoken/gapitoken.js:56:25)
at GAPI.getToken (/home/ubuntu/vikram/test/shock/node_modules/googleapis/node_modules/gapitoken/gapitoken.js:35:14)
at JWT.refreshToken_ (/home/ubuntu/vikram/test/shock/node_modules/googleapis/lib/auth/jwtclient.js:89:13)
at /home/ubuntu/vikram/test/shock/node_modules/googleapis/lib/auth/jwtclient.js:68:12
at /home/ubuntu/vikram/test/shock/node_modules/googleapis/node_modules/gapitoken/gapitoken.js:20:17
at fs.js:266:14
This doesn't really help me diagnose the issue. Can you post a code snippet I could use to reproduce the error?
I can't provide any code snippet, but the procedure is as follows:
Stream the data from a source (filesystem or API) Process that data into fields for Big Query Authenticate using JWT Stream the data to big query to save
Does this makes sense? If not i will write a sample code to replicate the error.
function InstertStreamInBQ(dataObj, tableName, callback){
// get authentication
jwtClient.authorize(function(err, tokens) {
if (err) {
console.log(err);
return;
}
// request body for big query
var request_body = {
"kind": "bigquery#tableDataInsertAllRequest",
"rows": [{
"insertId": dataObj.uuid,
"json": dataObj
}]
}
// save the data in big query's table
bq.tabledata.insertAll({
auth: jwtClient,
datasetId: config.datasetId,
projectId: config.projectId,
tableId: tableName,
resource: request_body
}, function(err, resp) {
if(err){
callback(err, null);
console.log("Error in bigquery stream save data @ bigquery.js : tableName ", err)
}else{
callback(null, resp);
});
}
This is the sample code I am using to stream data in bigquery and getting the same error during the load as described by @VikramTiwari. Could you pls suggest a way to overcome it.
Greetings folks! We've made a lot of changes to the auth library over the last few months, and there's a good chance this is fixed. If you're still running into problems, please feel free to open another issue!