首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >刷新OAuth2令牌时出错,消息:'{“错误”:"unauthorized_client","error_description“:”未经授权的客户端或请求中的范围“}。

刷新OAuth2令牌时出错,消息:'{“错误”:"unauthorized_client","error_description“:”未经授权的客户端或请求中的范围“}。
EN

Stack Overflow用户
提问于 2015-07-30 04:06:01
回答 1查看 20.6K关注 0票数 8

当我试图从获取数据时,我得到了错误

刷新OAuth2令牌时出错,消息:'{“错误”:"unauthorized_client","error_description“:”未经授权的客户端或请求中的范围“}。

我在https://console.developers.google.com/project中创建项目,创建服务帐户并下载.p12密钥。还可以在项目设置中启用"Analytics“,但它不起作用。这是我的密码:

代码语言:javascript
代码运行次数:0
运行
复制
    $service_account_name = '<Service Email>@developer.gserviceaccount.com';
    $key_file_location = '<keyName>.p12';
    $key = file_get_contents($key_file_location);
    $cred = new Google_Auth_AssertionCredentials(
        $service_account_name,
        array(Google_Service_Analytics::ANALYTICS),
        $key,
        'notasecret',
        'http://oauth.net/grant_type/jwt/1.0/bearer',
        '<My email>'
    );
$client->getAuth()->setAssertionCredentials($cred);
$service = new Google_Service_Analytics($client);
$result = $service->data_ga->get("ga:<profileID>", "yesterday", "today", "ga:pageviews");
print_r( $result);

我的项目有什么问题?请帮帮忙。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-14 14:27:15

您错过了最后一步,即在您的域的控制面板中提供对应用程序的访问权限。

https://developers.google.com/+/domains/authentication/delegation

您创建了服务帐户,现在需要委托/授权应用程序。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31715018

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档