【发布时间】:2015-08-22 08:51:57
【问题描述】:
我有以下代码
$client->setClientId('39605174446-s067746s1jur731n49fujigfh8occ5pa.apps.googleusercontent.com');
$client->setClientSecret('MYCLIENTSECRET');
$client->setRedirectUri('http://examplesss.com/oauth2');
$client->setScopes('https://picasaweb.google.com/data');
$client->setAccessType("offline");
我做了验证
在我的 Google 控制台 API 中,我将其设置为“Web 应用程序”,授权 Javascript 来源我将其留空。
我设置的授权重定向URI
http://example.com/oauth2
我去以下网站获取我的授权码
https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=&client_id=39605174446-s067746s1jur731n49fujigfh8occ5pa.apps.googleusercontent.com&redirect_uri=http://example.com/oauth2&response_type=code&scope=https://picasaweb.google.com/data&state=state
当我进入该站点时,我按确定授予“离线访问”权限。之后,我被重定向到一个不存在的站点,我使用的是 example.com,然后 URI 类似于
http://example.com/oauth2?state=stat&code=4/qWt9q19VtilG6Iw6HFte4RnpiXR0a5q80_zQAU-hNqc#
$client->authenticate('4/qWt9q19VtilG6Iw6HFte4RnpiXR0a5q80_zQAU-hNqc#');
然后我得到我的刷新令牌代码
$client->refreshToken('1\/vYnZlRcvaY2nD0yh5LhU9paLZZggMArGOo-3rEJHGCM');
但是当我运行代码时它说...
PHP Fatal error: Uncaught exception 'Google_Auth_Exception' with message 'Error refreshing the OAuth2 token, message: '{
"error" : "invalid_grant"
不知道出了什么问题,我只想访问我的 picasa 网络相册。
谢谢
【问题讨论】:
标签: javascript google-api google-api-php-client google-api-client