I want to access the Gmail API using NodeJS.
I use the server-to-server approach (see this ), but when I execute the code below, I get backEndError, code 500 from the Google API.
Any ideas?
var authClient = new google.auth.JWT( 'email', 'key.pem', // Contents of private_key.pem if you want to load the pem file yourself // (do not use the path parameter above if using this param) 'key', // Scopes can be specified either as an array or as a single, space-delimited string ['https://www.googleapis.com/auth/gmail.readonly'] ); authClient.authorize(function(err, tokens) { if (err) console.log(err); gmail.users.messages.list({ userId: 'me', auth: authClient }, function(err, resp) { // handle err and response if (err) { console.log(err); });
source share