调用报表API v1时出错

2024-10-06 12:58:21 发布

您现在位置:Python中文网/ 问答频道 /正文

调用报表API时出错:

<HttpError 403 when requesting https://www.googleapis.com/admin/reports/v1/usage/users/all/dates/2013-08-01?alt=json&maxResults=1 returned "Caller does not have access to the customers reporting data.">

以前有人见过这个错误吗?我错过了什么? 我就是不明白这是为什么,或者我应该检查什么。在

敬上。在

编辑:

授权:

^{pr2}$

实际通话:

result = service.userUsageReport().get(
    userKey='all',
    date='2013-08-01',
    maxResults=1).execute()

其他api可以很好地使用该服务帐户。 “https://www.googleapis.com/auth/admin.reports.usage.readonly”已正确添加到OAuth2域配置页。在


Tags: httpscomapi报表adminwwwusageall
1条回答
网友
1楼 · 发布于 2024-10-06 12:58:21

尝试:

    credentials = SignedJwtAssertionCredentials(
        service_account_name='5163XXXXX@developer.gserviceaccount.com',
        private_key=oauth2_private_key,
        scope='https://www.googleapis.com/auth/admin.reports.usage.readonly',
        sub='super-admin@yourdomain.com')

在使用adminisdk的服务帐户时,您仍然需要代表googleapps实例中的管理员。在

另外,请确保服务帐户客户机ID已被授予使用Google Apps控制面板中Reports API作用域的权限。googledrive文档describe this process well,只是在Reports范围内进行sub。在

相关问题 更多 >