我怎样才能得到一个特定的人发送的电子邮件列表?

我正在使用Google Gmail API来获取消息列表。 我想要做的是获得从特定用户发送的所有消息的列表。 这是我到目前为止:

var oauth2Client = new OAuth2('', '', ''); oauth2Client.setCredentials(token); var gmail = google.gmail('v1'); gmail.users.messages.list({ auth: oauth2Client, userId: 'me' }, function(err, response) { if (err) { console.log('The API returned an error: ' + err); cb(null, false); } else { cb(null, response); } }); 

我试着设置userId: 'person@email.com'但是这给了我以下错误:

 The API returned an error: Error: Delegation denied for person@email.com 

我错过了什么? 提前谢谢任何答案!

你应该使用像这样的值的q参数: from:person@email.com 。 它会from来滤除电子邮件。 然后,您尝试使用userId: 'person@email.com Google API认为您需要来自person@email.com收件箱的电子邮件列表(但您无权访问它)。