You do not have permission to call getContacts

2019-08-10 13:15发布

I'm developing the GMail Add-on that pulls out all user's contacts to card:

var contacts = ContactsApp.getContacts();

I already enabled ContactsAPI in Google API Console and added scope: https://www.googleapis.com/auth/contacts.readonly

But the error is still there and the Contacts API is missing in the project's Advanced Google Service pop-up.

2条回答
一夜七次
2楼-- · 2019-08-10 14:02

Through trial and error, and this hard-to-find list I managed to get ContactsApp.getContacts() to work. You need to add this scope:

"oauthScopes": [
  "https://www.google.com/m8/feeds",
查看更多
Summer. ? 凉城
3楼-- · 2019-08-10 14:07

There is no need to enable Contacts API and set the scope when using the ContactsApp. When using this, upon reviewing the permission to be used, your app will automatically select the necessary permission for ContactsApp to work properly.

I've use the same code as yours:

function myFunction() {
  // The code below will retrieve all the user's contacts
 var contacts = ContactsApp.getContacts();

  Logger.log(contacts)
}

Here is the result I received:

enter image description here

Kindly check and review your code, you might have missed something.

Hope this helps.

查看更多
登录 后发表回答