我有以下代码:
$this->client = new Google_Client();
$this->client->setAuthConfig(FCPATH . 'google-api-php-client-master'.DIRECTORY_SEPARATOR.'client_secret.json');
$this->client->setRedirectUri($redirect_uri);
$this->client->addScope("https://www.googleapis.com/auth/calendar");
$this->client->setAccessType('offline');
$this->client->setApprovalPrompt("force");
$this->client->setAccessToken($access_token);
if ($this->client->isAccessTokenExpired()) {
$this->client->refreshToken($this->client->getRefreshToken());
print_r($this->client->getAccessToken());
}
当我使用print_r获取访问令牌时,我得到了以下没有刷新令牌的数组:
Array
(
[access_token] => ya29.LwIjjaXB1kGunCp8EzwMwmaO4eoDsqbdoRFNjWhcDvw59RtDnT6mbjlauX3PM6irbMfg
[token_type] => Bearer
[expires_in] => 3600
[created] => 1447747649
)
但我希望得到一个带刷新令牌的数组,例如:
Array
(
[access_token] => ya29.LwIjjaXB1kGunCp8EzwMwmaO4eoDsqbdoRFNjWhcDvw59RtDnT6mbjlauX3PM6irbMfg
[token_type] => Bearer
[expires_in] => 3600
[refresh_token] => 1/wzTZcDm2fzZD9y3Ixr2gczgC5iD1zifVSGQoijCu4vlIgOrJDtdun6zK6XiATCKT
[created] => 1447747649
)