Using Google Apps Script API to access another user

我怕爱的太早我们不能终老 提交于 2021-02-07 20:30:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!