Google Analytics PHP API“(403)权限不足"; [英] Google Analytics PHP API "(403) Insufficient Permission"

查看:121
本文介绍了Google Analytics PHP API“(403)权限不足";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,正如标题所示,Google Analytics API有问题...

Ok So as the title suggest Google Analytics API Problems...

现在,在我开始之前,有一些管道已经重复....我已经读过

Now before i start and some one pipes up Duplicate.... i have read though

403权限不足错误,尝试执行以下操作:获取Google Analytics(分析)数据

Google Analytics(分析)API错误403:用户没有任何Google Analytics(分析)帐户"

Google Analytics(分析)API:";用户对该帐户没有足够的权限."

仍然无法使其正常工作. 我像这样添加了作用域:

And still unable to get it to work. I have the scope added like so:

$client->addScope("https://www.googleapis.com/auth/analytics");

按现状,我正在尝试查看视图ID(配置文件):46034120 这样我就可以得到服务

As it stands i have the view id (profile) i'm trying to query:46034120 So i get the service

$this->service = new \Google_Service_Analytics($client);

我打电话给

$this->service->data_ga->get(
    'ga:46034120',
    '7daysAgo',
    'today',
    'ga:session');

对于开始时的问题,我已经确保可以从登录到Google的oAuth2.0系统的Google帐户访问此视图.因此,用户绝对有权访问该视图.我还确保将developer.googleservice电子邮件地址添加到Google Analytics(分析)中,并且仍然无法使用.

As for the questions at the start i have made sure that this view can be access from the Google Account that is logged into the the oAuth2.0 system for Google. so the user defiantly has permissions to access this view. i have also made sure that the developer.googleservice email address is added into Google Analytics and it still wont work.

范围:

{
 "issued_to": "140914874329-48n4vvp54irhf2j2hqieev32qukstc8e.apps.googleusercontent.com",
 "audience": "140914874329-48n4vvp54irhf2j2hqieev32qukstc8e.apps.googleusercontent.com",
 "user_id": "113401197174555518304",
 "scope": "https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/analytics.readonly https://www.googleapis.com/auth/plus.moments.write https://www.googleapis.com/auth/plus.profile.agerange.read https://www.googleapis.com/auth/plus.profile.language.read https://www.googleapis.com/auth/plus.circles.members.read",
 "expires_in": 3497,
 "access_type": "offline"
}

它非常清楚地说" https://www.googleapis.com/auth/analytics .readonly "

推荐答案

您可以通过调用来检查授予的令牌

You can check a granted token via a call to

https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=accessToken.

在那里,您可能会看到用户ID和已授予的范围.如果您没有访问权限,则您的权限显然不足.

There, you may see the user id and granted scopes. If you do not have access, your permissions are obviously insufficient.

这篇关于Google Analytics PHP API“(403)权限不足";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆