Reputation: 33
I am working on one project for a client, and I need to add contacts to Google Contacts
with Google Contacts API
. The code:
function createContact(data) {
var contact = ContactsApp.createContact(data.firstName, data.lastName, data.email);
contact.addAddress(data.address);
}
runs on the trigger and I am getting this error: Exception: You do not have permission to perform that action.
(the same happens when I run the function from the Editor). I added permissions to the project (Permissions screenshot) and scope to the appsscript.json
file:
"oauthScopes": [
"https://www.google.com/m8/feeds"
]
Additional question: If I have got this project in my Google Account, how I can access to Google Contacts and add contacts to the client's Google account?
Upvotes: 2
Views: 323
Reputation: 1459
I'm assuming that you are running a simple trigger. This is what the official documentation says about this:
They cannot access services that require authorization. For example, a simple trigger cannot send an email because the Gmail service requires authorization, but a simple trigger can translate a phrase with the Language service, which is anonymous.
You probably need to change your workflow and use an installable trigger or something else. If you need help with that, feel free to create a new question.
Upvotes: 1