thephpleague / oauth2-client

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

AccessToken setTimeNow is useless function #1012

Open androidealp opened 1 year ago

androidealp commented 1 year 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....
     }
}