MMM
MMM

Reputation: 113

You do not have permission to call getContacts

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.

Upvotes: 3

Views: 1558

Answers (2)

wulftone
wulftone

Reputation: 1708

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",

Upvotes: 2

Mr.Rebot
Mr.Rebot

Reputation: 6791

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.

Upvotes: 0

Related Questions