Question

I am trying to use the BigQuery package found here: https://www.npmjs.org/package/bigquery

Setup: Ubuntu 14, latest Node, nginx, plus that bigquery package and its dependencies.

I believe I've set it up correctly, including the PEM files, but I am getting an error from gauth when I try to load the key files:

[2014-05-04 02:14:57.008] [ERROR] gauth - { [Error: ENOENT, open './key.mydomain.com.p12.pem']
  errno: 34,
  code: 'ENOENT',
  path: './key.mydomain.com.p12.pem' }
Error: ENOENT, open './key.mydomain.com.p12.pem'

I am running just a simple test script that looks like so (I've Xxxx'd out my project ID):

var http = require('http')
  , bq = require('bigquery')
  , fs = require('fs')
  , prjId = 'xxxxxxxxxx'; //you need to modify this

bq.init({
    scope: 'https://www.googleapis.com/auth/bigquery',
    client_secret: './client_secrets.json',
    privatekey_pem: './private.mydomain.com.p12.pem',
    key_pem: './key.mydomain.com.p12.pem'
  });


http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.write('Testing BigQuery... \n');

    bq.job.query(prjId, 'select count(*) from publicdata:samples.wikipedia', function(e,r,d){
      if(e) console.log(e);
      console.log( JSON.stringify(d) );
    });

    res.end('Done. \n');
}).listen(3000, "127.0.0.1");
console.log('Server running at http://127.0.0.1:3000/');

I've tried referencing the file different, using __dirname and also no slashes.

Any thoughts? I'm looking at the Google code in the dependencies, too, but just not figuring this one out.

Was it helpful?

Solution 2

Ah, figured it out: the P12 file I used to generate the private and public keys was mismatched with my client_secrets.

So, if anyone else gets this issue, the ENOENT could be caused by have a client_secrets.json and a set of keys for a service account that were not created together.

OTHER TIPS

A 34 error means 'no such file or directory'. Are you sure the file key.mydomain.com.p12.pem exists in the same directory as your index file?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top