1

I'm trying to call Ganalytics from app-script, but I get an error about missing scopes.

I couldn't find documentation about where I should put the "scope" property (it just says under request options).

Is this the right syntax?

function getEventsFromAnalytics() {
  var url = 'https://analyticsdata.googleapis.com/v1beta/properties/1234:runReport';
  var token = ScriptApp.getOAuthToken();
  Logger.log(`token is ${token}`)
 
var auth = "Bearer " + token;
var myHeaders = {
  "Authorization": auth
}


var requestOptions = {
  'contentType': 'application/json',
  'headers': myHeaders,
  'method' : 'post',
  'payload' : rawdata, 
  'followRedirects': true,
   'muteHttpExceptions' : true,
   'scope':  'https://www.googleapis.com/auth/analytics.readonly'
};
Elad Benda
  • 35,076
  • 87
  • 265
  • 471
  • This seems to do https://stackoverflow.com/questions/46729469/how-to-narrow-down-the-auth-drive-scope-for-a-google-apps-script – Elad Benda Jul 26 '21 at 12:12

0 Answers0