脚本宝典收集整理的这篇文章主要介绍了php – 刷新OAuth2令牌时出错,消息:'{“error”:“unauthorized_client”,“error_description”:“请求中未经授权的客户端或范围.”}’,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在https://console.developers.google.com/project创建项目,创建服务帐户并下载.p12密钥.同时在项目设置中启用“Analytics API”,但它不起作用.这是我的代码:
$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);
我的项目有什么问题?请帮忙.
https://developers.google.com/+/domains/authentication/delegation
您创建了服务帐户,现在需要委派/授权该应用程序.
以上是脚本宝典为你收集整理的php – 刷新OAuth2令牌时出错,消息:'{“error”:“unauthorized_client”,“error_description”:“请求中未经授权的客户端或范围.”}’全部内容,希望文章能够帮你解决php – 刷新OAuth2令牌时出错,消息:'{“error”:“unauthorized_client”,“error_description”:“请求中未经授权的客户端或范围.”}’所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。