缺少范围Google AnalyticsAPI

时间:2018-05-01 07:14:01

标签: javascript google-apps-script google-oauth google-analytics-api

所以我在Google APPs脚本上使用OAuth2库,通过post和get请求连接到Google API。现在,在尝试连接到Google Analytics和Google Analytics Reporting API时,我得到了

  

“请求的身份验证范围不足”。

以下是生成我的服务的函数:

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');
}

正如你所看到的那样,我已将所有范围都包括在阳光下,所以我希望有人可以在这里提供帮助。

0 个答案:

没有答案