thephpleague / oauth2-client

Easy integration with OAuth 2.0 service providers.

Home Page:http://oauth2-client.thephpleague.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AccessToken setTimeNow is useless function

androidealp opened this issue · comments

token depends on the expiration date, currently the self::$timeNow attribute is null so getTimeNow() returns the current time() and not the one determined by the auth token.

my Solution:

public function checkExpires(AccessToken $accessToken, $tokenObject){
        $expires = $accessToken->getTimeNow() + $tokenObject['expires_in'];
        return ($expires < time());
    }

public function myCode($accessToken, $tokenObject, $bdTokenObject){
   $accessToken->setTimeNow($bdTokenObject->dt_create);

     if($this->checkExpires($accessToken, $tokenObject)){
     // token expired....
     }
}