使用服务帐号的Google报告API

huangapple go评论98阅读模式
英文:

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

huangapple
  • 本文由 发表于 2015年10月16日 23:15:09
  • 转载请务必保留本文链接:https://go.coder-hub.com/33173938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定