Closed nexus-uw closed 10 years ago
Configure a JWT auth client with your service account email and the pem file that contains your private key. Google Developers Console only provide p12 files, you can convert a p12 to pem with the following command:
openssl pkcs12 -in <key.p12> -nocerts -passin pass:notasecret -nodes -out <key.pem>
Construct a jwt client, and auth your requests.
var jwt = new googleapis.auth.JWT(
'serviceaccount@email.com',
'/path/to/key.pem',
null,
[scope1, scope2],
'bar@subjectaccount.com');
client.drive.files.list().withAuthClient(jwt).execute(function(err, files) {
});
thank you
I don't think this issue should be closed until there is something about this in the documentation. Had I not hunted through the closed issues, this information would have been lost to me.
@coreybutler Added a section to the README: https://github.com/google/google-api-nodejs-client#using-jwt-service-tokens
Let me know if this suits your fancy.
@ryanseys - yup, thanks!
Currently, only making requests as the authorized user is documented. I would like to be able to know how to properly make api calls as a service account (aka use jwt authorization). I am currently grasping at straws as every so often the library crashes due to some error in the jwt authorize call, see: