thephpleague / oauth2-client

Easy integration with OAuth 2.0 service providers.
http://oauth2-client.thephpleague.com
MIT License
3.63k stars 751 forks source link

AccessToken setTimeNow is useless function #1012

Open androidealp opened 9 months ago

androidealp commented 9 months ago

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....
     }
}