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.