Google 分析 API

Google Analytics API

我正在实施 google 分析 Api。

授权是在没有 problems.After 成功授权的情况下完成的 我得到 403 return code 并收到消息:User does not have sufficient permissions for this profile.

我的帐户有 google 分析数据,跟踪多个网站,我可以毫无问题地从网络浏览器访问它。我已通过 google api 控制台允许 Analytics api。

这是我在成功授权后得到的响应:

array(2) {
  ["http_code"]=>
  int(403)
  ["error"]=>
  array(3) {
    ["errors"]=>
    array(1) {
      [0]=>
      array(3) {
        ["domain"]=>
        string(6) "global"
        ["reason"]=>
        string(23) "insufficientPermissions"
        ["message"]=>
        string(59) "User does not have sufficient permissions for this profile."
      }
    }
    ["code"]=>
    int(403)
    ["message"]=>
    string(59) "User does not have sufficient permissions for this profile."
  }
}

我们将不胜感激任何直接的帮助。谢谢

您用来进行身份验证的 Google 帐户 无权访问您尝试查看访问权限的 Google Analytics profile / view

选项:

  1. 使用有权访问该个人资料的帐户登录。
  2. 授予您正在登录的用户访问该个人资料的权限
  3. 仔细检查您的个人资料 ID 是否正确:)

如果您使用的是服务帐户,请获取服务帐户电子邮件地址并将其作为 ACCOUNT 级别的用户添加到 Google Analytics 帐户你会任何用户。

当您未授予访问权限或令牌已过期时,该错误很常见,请尝试检查这些参数。为此,您必须攻击以下范围。

https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=xxxxxxxxxxxx

(请记住将 x 替换为您的令牌)

{
         "azp": "1044214436568-xxxxxxxxxxx.apps.googleusercontent.com",
         "aud": "1044214436568-xxxxxxxxxxxxxx.apps.googleusercontent.com",
         "scope": "https://www.googleapis.com/auth/analytics.readonly",
         "exp": "1467026930",
         "expires_in": "3287",
         "access_type": "offline"
}

尝试使用正确的标记命中正确的范围参数(在本例中为“https://www.googleapis.com/auth/analytics.readonly”)

如果您需要更多帮助,请添加此信息以查看您的错误所在