Pergunta

I am currently working on a node.js app which should create events in google calendar. On my machine (OS X 10.9.2) it works well, but on another machine (Debian 7 Wheezy 64-bit) it does not work. Both have installed the same node.js version: v0.10.26. I always get the following error:

crypto.js:398
var ret = this._binding.sign(toBuf(key));
                      ^
TypeError: Not a buffer
at Sign.sign (crypto.js:398:27)
at createRS256Signature (/path/to/node_app/node_modules/googleapis/node_modules/gapitoken/node_modules/jws/index.js:75:58)
at jwsRS256Sign (/path/to/node_app/node_modules/googleapis/node_modules/gapitoken/node_modules/jws/index.js:68:21)
at Object.jwsSign [as sign] (/path/to/node_app/node_modules/googleapis/node_modules/gapitoken/node_modules/jws/index.js:32:12)
at GAPI.getAccessToken (/path/to/node_app/node_modules/googleapis/node_modules/gapitoken/gapitoken.js:56:25)
at GAPI.getToken (/path/to/node_app/node_modules/googleapis/node_modules/gapitoken/gapitoken.js:35:14)
at JWT.refreshToken_ (/path/to/node_app/node_modules/googleapis/lib/auth/jwtclient.js:83:13)
at /path/to/node_app/node_modules/googleapis/lib/auth/jwtclient.js:64:12
at /path/to/node_app/node_modules/googleapis/node_modules/gapitoken/gapitoken.js:20:17
at fs.js:266:14

The code that causes this error:

this.jwt = new googleapis.auth.JWT(
    SERVICE_ACCOUNT_EMAIL,
    SERVICE_ACCOUNT_KEY_FILE,
    null,
    ['https://www.googleapis.com/auth/calendar', 'https://www.googleapis.com/auth/calendar.readonly']);

SERVICE_ACCOUNT_KEY_FILE is the path to my .pem keyfile, which also can be found by the application.

Everything works locally, but not on the Debian machine. Do I have to install some dependencies or something similar?

EDIT1: I also tried passing the key as a string via the third argument, but that didn't work either.

Thank you!

Foi útil?

Solução

I fixed it by getting the key from file and then passing it as key argument instead of keyfile. It seems as if the key did not get read due to an async file access issue.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top