我使用Hybridauth 2.3.0库和CodeIgniter框架,我遇到了一个问题。我的问题是刷新令牌总是空的。
混合\ Provider_Model_OAuth2.php:
function refreshToken()
{
// have an access token?
if( $this->api->access_token ){
// have to refresh?
//==> $this->api->refresh_token always return false (empty)
if( $this->api->refresh_token && $this->api->access_token_expires_at ){
// expired?
if( $this->api->access_token_expires_at <= time() ){
$response = $this->api->refreshToken( array("refresh_token" => $this->api->refresh_token ) );
if( ! isset( $response->access_token ) || ! $response->access_token ){
// set the user as disconnected at this point and throw an exception
$this->setUserUnconnected();
throw new Exception( "The Authorization Service has return an invalid response while requesting a new access token. " . (string) $response->error );
}
// set new access_token
$this->api->access_token = $response->access_token;
if( isset( $response->refresh_token ) )
$this->api->refresh_token = $response->refresh_token;
if( isset( $response->expires_in ) ){
$this->api->access_token_expires_in = $response->expires_in;
// even given by some idp, we should calculate this
$this->api->access_token_expires_at = time() + $response->expires_in;
}
}
}
// re store tokens
$this->token( "access_token" , $this->api->access_token );
$this->token( "refresh_token", $this->api->refresh_token );
$this->token( "expires_in" , $this->api->access_token_expires_in );
$this->token( "expires_at" , $this->api->access_token_expires_at );
}
}
这意味着当访问令牌到期时,此时会触发异常,如下所示:
混合\提供商\ Google.php:
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
因此用户必须注销并再次登录。 我该怎么做才能解决这个问题? 感谢