我正在尝试使用Google PHP API从Google plus中播放内容。我能够获得刷新令牌。但是当我尝试使用该刷新令牌获取访问令牌时,它返回以下错误。
致命错误:未捕获的异常' apiAuthException'有消息'错误刷新OAuth2令牌,消息:' {"错误" :" invalid_grant" }''在/var/www/social-media-test/google-api-php-client/src/auth/apiOAuth2.php:242堆栈跟踪:#0 / var / www / social-media-test / google-api-php -client / src / apiClient.php(281):apiOAuth2-> refreshToken(' MY-REFRESH-TOKEN-HERE')#1 / var / www / social-media-test / google-api- php-client / examples / plus / p.php(19):apiClient-> refreshToken(' MY-REFRESH-TOKEN-HERE')/ var / www / social-中引发#2 {main}第242行的media-test / google-api-php-client / src / auth / apiOAuth2.php
我的代码如下所示。
$client = new apiClient();
$client->setApplicationName('Google+ PHP Starter Application');
$client->setClientId('client-id');
$client->setClientSecret('secret-key');
$client->setRedirectUri('http://localhost/index.php/main');
$client->setDeveloperKey('dev-key');
$plus = new apiPlusService($client);
$client->refreshToken('MY-REFRESH-TOKEN');
任何想法?
答案 0 :(得分:0)
$client->setScopes(array(
'https://www.googleapis.com/auth/blogger'
));
参考:https://developers.google.com/gdata/docs/auth/oauth#Scope