Trouble on the quickstart using app script
Expected Behavior
Hey guys,
I followed tutorial on google app script quick start for gmail API here
What i'm getting in the app script is this
GoogleJsonResponseException: API call to gmail.users.labels.list failed with error: Request had insufficient authentication scopes. (line 5, file "Code")
The code followed is exactly the same as the tutorial, I also enabled gmail in Resources > Advance Google Service
/**
* Lists the labels in the user's account.
*/
function listLabels() {
var response = Gmail.Users.Labels.list('me');
if (response.labels.length == 0) {
Logger.log('No labels found.');
} else {
Logger.log('Labels:');
for (var i = 0; i < response.labels.length; i++) {
var label = response.labels[i];
Logger.log('- %s', label.name);
}
}
}
I thought its going to be easier for me to integrate stuff in google ecosystem. Right now my other way is to create my own server and use node js to use gmail api. can anyone help me please?
Thanks
@Bluefitdev ,
I just created a new Script, added the code, activated the API, clicked debugger to trigger the Apps authentication, ran the code, then viewed the execution log. Everything worked fine. Are you using your personal Gmail or an Apps account? (i.e. a business Google Account)


Hey it was a business account. GSuite connected account, is there any difference?
It worked fine after I put it to nodejs sdk though...
@robertwt7 ,
In GSuite the use of the API's can be turned off at the account level and in my experience you don't find that out until you try to run the selected API.
@robertwt7 ,
In GSuite the use of the API's can be turned off at the account level and in my experience you don't find that out until you try to run the selected API.
Just verified. I was testing Email Markup in Apps Script, and no sample code in tutorial is working in my G Suite/Google Workplace accounts.
But the sample code works perfectly in my personal Google account.
Seems like APIs of my G Suite/Google Workplace accounts have been disabled.