oauth2-fitbit
                                
                                
                                
                                    oauth2-fitbit copied to clipboard
                            
                            
                            
                        How can I guess AccesToken object with a token String
Hello, I want to know if my token has expired, I update my database with all the token information (auth code, token, refresh_token, expires) and I would like to call $token->hasExpired(), but I do not know how to get an AccessToken object ($token) to call the function. I have tried $this->provider->getAccessToken('access_token', ['access_token'=>$string]) but I tried it more out of desperation than anything.
I would recommend directly checking that expires value from the database against the current time to see if its expired.
It's not possible to reconstruct the AccessToken object with simply the token string.
However if you have all of the necessary fields from AccessToken stored in your database, you can use its constructor to create a new instance with those values:
https://github.com/thephpleague/oauth2-client/blob/master/src/Token/AccessToken.php#L59
You'll need to pass in that $options array with access_token, refresh_token, expires_in, etc.