首页 > 解决方案 > 无法通过 gmail 插件访问 gmail 联系人(已包含 oauth 范围)

问题描述

我正在尝试在我的插件中执行此操作,但出现错误

您无权调用 getContact [line: 37, function: addOnLogic, file: app]

var contact = ContactsApp.getContact('john.doe@example.com');

我添加了以下范围。

"oauthScopes": [
"https://www.googleapis.com/auth/gmail.addons.execute", 
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.compose",
"https://www.googleapis.com/auth/gmail.addons.current.action.compose", 
"https://www.googleapis.com/auth/script.external_request",
"https://www.google.com/m8/feeds/",
"https://www.googleapis.com/auth/contacts" ]

允许 : 权限

标签: google-apps-scriptgmail-addons

解决方案


从这个SO 帖子中,建议添加这个范围

"oauthScopes": [
  "https://www.google.com/m8/feeds",

为了ContactsApp.getContacts()工作。


推荐阅读