首页 > 解决方案 > 谷歌工作区 API 的访问被拒绝

问题描述

我试图访问谷歌工作区 api。api 文档链接 - https://developers.google.com/admin-sdk/reports/reference/rest 访问 api,需要发送 header 的访问令牌。所以我执行以下步骤,第 1 步 - 创建 oauth 2.0 gcp 中的凭据。然后获取 clientId 和 clientSecret。第 2 步 - 我将谷歌工作区域范围委派添加到 clientId 和范围。第 3 步 - 我正在使用 OAuth 2.0 Playground ( https://developers.google.com/oauthplayground ) 提供 clientid 和 clientsecret。选择https://www.googleapis.com/auth/admin.reports.audit.readonly、https://www.googleapis.com/auth/admin.reports.usage.readonly的范围。我正在获取访问令牌。在我尝试了api之后。

API - https://admin.googleapis.com/admin/reports/v1/activity/users/all/applications/login 错误 - { "error": { "message": "访问被拒绝。您无权阅读活动记录。”,“代码”:401,“错误”:[ {“原因”:“authError”,“locationType”:“标题”,“消息”:“访问被拒绝。您无权读取活动记录。” ,“域”:“全球”,“位置”:“授权”}]}}

标签: google-admin-sdkgoogle-workspace

解决方案


推荐阅读