Google OAuth 0.2无效授权

时间:2015-08-22 08:51:58

标签: javascript google-api google-api-php-client google-api-client

我有以下代码

$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 Console 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网络相册。

感谢

0 个答案:

没有答案
相关问题