我试图在他过期后得到一个新的access_token。我已经在银行存的回报,我收到信息的第一客户端访问:Google API - 刷新令牌
{"access_token": "TOKEN", "refresh_token": "TOKEN", "token_type", "Bearer", "expires_in": 3600, "created ": 1320790426}
之后令牌到期我需要申请一个新的,我做的是这样的:
$client = new Google_Client();
$client->setApplicationName(APPLICATION_NAME);
$client->setScopes(SCOPES);
$client->setAuthConfigFile(CLIENT_SECRET_PATH);
$client->setAccessType('offline');
$token['access_token'] = $db->dados[0]['use_access_token'];
$token['refresh_token'] = $db->dados[0]['use_refresh_token'];
$token['token_type'] = $db->dados[0]['use_token_type'];
$token['expires_in'] = $db->dados[0]['use_expires_in'];
$token['created'] = $db->dados[0]['use_created'];
$client->setAccessToken(json_encode($token));
if ($client->isAccessTokenExpired()) {
echo "Expired !";
$client->refreshToken($client->getRefreshToken());
//$accessToken = $client->authenticate($authCode);
} else {
...
}
问题是,总是返回此错误: 错误刷新的OAuth2令牌,消息:
{ "error" : "invalid_grant" }
如何迪d获取,提取并将刷新标记存储在数据库中(即您通过$ db-> dados [0] ['use_refresh_token']'检索的值;你可能想要粘贴该代码以及 –