0
nodejsのgoogle APIを使用してGmailの受信トレイを読み込もうとしています。 それはNULL値(メッセージ)、メッセージIDを与えるこのコードイムで を返すには、直接Gmailの受信トレイのリンクnull値は、GoogleのAPIを使用してGmailの受信トレイを読むときに発生します。
(function() {
'use strict';
var fs = require('fs');
var googleAuth = require('google-auth-library');
var google = require('googleapis');
function getOAuth2Client(cb) {
// Load client secrets
fs.readFile('client_secret.json', function(err, data) {
if (err) {
return cb(err);
}
var credentials = JSON.parse(data);
var clientSecret = credentials.installed.client_secret;
var clientId = credentials.installed.client_id;
var redirectUrl = credentials.installed.redirect_uris[0];
var auth = new googleAuth();
var oauth2Client = new auth.OAuth2(clientId, clientSecret, redirectUrl);
// Load credentials
fs.readFile('gmail-credentials.json', function(err, token) {
if (err) {
return cb(err);
} else {
oauth2Client.credentials = JSON.parse(token);
return cb(null, oauth2Client);
}
});
});
}
function getMessage(auth) {
var gmail = google.gmail({ auth: auth, version: 'v1' });
gmail.users.messages.get({
'userId': 'me',
'id': '153a1f810aece662'
}, function (err, result) {
console.log(result);
});
}
getOAuth2Client(function(err, oauth2Client) {
if (err) {
console.log('err:', err);
} else {
console.log(oauth2Client);
getMessage(oauth2Client, function(err, results) {
if (err) {
console.log('err:', err);
} else {
console.log(results);
}
});
}
});
})();
OAuth認証データが完全に働いているが、nullが
エラー{[エラー:十分な権限] コード:403、 エラー: [{ドメイン: 'グローバル'、 理由: 'insufficientPermissions'、 メッセージ:「不十分なアクセス許可」}]} –
これは私の出力です –
あなたのGmail APIに「不十分なアクセス許可」があることがわかりますので、http: //stackoverflow.com/questions/32143126/how-do-i-get-around-httperror-403-insufficient-permission-gmail-api-python、http://stackoverflow.com/questions/30661489/gmail-api-不十分な許可 – shershen