Gmail API是否支持JWT?

我想使用NodeJS访问Gmail API。

我正在使用服务器到服务器的方法(请参阅此 ),但是当我执行下面的代码时,我得到一个backEndError,来自Google API的代码500。

有任何想法吗?

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); }); 

是的,我有同样的问题。 如果我使用范围“ https://mail.google.com ”,我得到

 403 { "error" : "access_denied", "error_description" : "Requested client not authorized." } 

如果我使用范围“ https://mail.google.com/ ”(注意/在最后),我得到

 403 'Forbidden' 

这似乎与使用JWT和服务帐户有关。