2

So I am using the OAuth2 Library on Google APPs script, to connect to Google APIs via post and get requests. Now while trying to connect to Google Analytics and Google Analytics Reporting APIs i get

"Request had insufficient authentication scopes".

Here is the Function which generates my service:

function getService_() {

return OAuth2.createService('GService')
.setAuthorizationBaseUrl('https://accounts.google.com/o/oauth2/auth')
.setTokenUrl('https://accounts.google.com/o/oauth2/token')
.setClientId(GOOGLE_SECRET_AND_CLIENTID)
.setClientSecret(GOOGLE_SECRET_AND_CLIENTID)
.setCallbackFunction('authCallbackBQ')
.setPropertyStore(PropertiesService.getUserProperties())
.setScope(['https://www.googleapis.com/auth/bigquery',
         'https://www.googleapis.com/auth/devstorage.full_control',
         'https://www.googleapis.com/auth/devstorage.read_write',
         'https://www.googleapis.com/auth/cloud-platform',
         'https://www.googleapis.com/auth/analytics',
         'https://www.googleapis.com/auth/analytics.readonly',
         'https://www.googleapis.com/auth/analytics.edit',
         'https://www.googleapis.com/auth/analytics.manage.users',
         'https://www.googleapis.com/auth/analytics.manage.users.readonly',
         'https://www.googleapis.com/auth/analytics.provision'])
  .setParam('access_type', 'offline');
}

As you can see I've included every scope under the sun, so i am hoping somebody could help out here.

Sourabh Choraria
  • 2,255
  • 25
  • 64
Rohod
  • 51
  • 3
  • Possible duplicate of [Google spreadsheet api Request had insufficient authentication scopes](https://stackoverflow.com/questions/38534801/google-spreadsheet-api-request-had-insufficient-authentication-scopes) – hungrykoala May 01 '18 at 07:16
  • Step one stop requesting every scope under the sun. Step two reauthorize you probably authenticated once without the required scope and its complaining becouse it needs to be reset. https://www.googleapis.com/auth/analytics will give you everything. – Linda Lawton - DaImTo May 01 '18 at 07:17
  • @hungrykoala this is app scripts not node.js you might want to wait until you have the privileges to mark things duplicate before commenting them as duplicate. – Linda Lawton - DaImTo May 01 '18 at 07:18
  • The answer to that post has some detailed information on how to go about solving the problem. [here](https://stackoverflow.com/a/38541482/6444625) or [this](https://stackoverflow.com/a/41534745/6444625) – hungrykoala May 01 '18 at 07:21

0 Answers0