问题
I'm really confused with this. I want to use the Gmail API to access and send mail in another account using google apps script. I have enabled Gmail in the Advanced Google Services and have enabled the API on the console. The following code works when I use a value of 'me' but when I try it for another user I get a 'Delegation denied' error. I fully understand that I can't just put in whatever email address I want and expect to be able to access it, but I can't seem to find/understand the documentation that lays out the steps to allow this to work.
function listLabels() {
var response = Gmail.Users.Labels.list('user@example.com');
Logger.log("Labels:");
for (var i = 0; i < response.labels.length; i++) {
var label = response.labels[i];
Logger.log("- %s", label.name);
}
}
来源:https://stackoverflow.com/questions/40855997/using-google-apps-script-api-to-access-another-user