If someone else using JWT authentication in the Google API comes across this question (for example, when using service accounts), be sure to include auth: <your jwtClient> in your API call, for example:
First enter the token:
// Configure JWT auth client var privatekey = require("./<secret>.json") var jwtClient = new google.auth.JWT( privatekey.client_email, null, privatekey.private_key, ['https://www.googleapis.com/auth/drive'] ); // Authenticate request jwtClient.authorize(function (err, tokens) { if (err) { return; } else { console.log("Google autorization complete"); } });
Then call the API (but don't forget the auth:jwtClient )
drive.files.create({ auth: jwtClient, resource: {<fileMetadata>}, fields: 'id' }, function (err, file) { if (err) {
source share