英文:
Google Reports API with a service account
问题
我正在尝试使用服务帐号调用Google Reports API。
我按照这个代码示例进行操作:https://godoc.org/golang.org/x/oauth2/google#JWTConfigFromJSON
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Access denied. You are not authorized to read activity records.",
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Access denied. You are not authorized to read activity records."
}
}
我相当确定问题出在Google的配置方面,但是:
- 我创建了服务帐号
- 我下载了JWT
- 我授权了所需的范围
然后我尝试调用这个URL:https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/login
我可能忘记了什么?
谢谢你的帮助。
英文:
I'm trying to make a call to Google Reports API with a service account.
I follow this code example : https://godoc.org/golang.org/x/oauth2/google#JWTConfigFromJSON
{
"error": {
"errors": [
{
"domain": "global",
"reason": "authError",
"message": "Access denied. You are not authorized to read activity records."
,
"locationType": "header",
"location": "Authorization"
}
],
"code": 401,
"message": "Access denied. You are not authorized to read activity records."
}
}
I'm pretty sure it is on Google configuration side but :
- I created the service account
- I downloaded the JWT
- I authorized the needed scopes
Then I try to call this URL : https://www.googleapis.com/admin/reports/v1/activity/users/all/applications/login
What could I have forget ?
Thanks for helping me.
答案1
得分: 0
已修复。需要明确指定主题值。
我现在遵循服务帐户示例:https://godoc.org/golang.org/x/oauth2/google
英文:
Fixed it. Needed to explicitly specify the subject value.
I now follow the Service Account example : https://godoc.org/golang.org/x/oauth2/google
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论