Should be a way to get the unix timestamp of the OAuth2 token expiration dates. #527
Description
As can be seen here:
https://github.com/intuit/QuickBooks-V3-PHP-SDK/blob/master/src/Core/OAuth/OAuth2/OAuth2AccessToken.php#L252-L259
The token expiration dates are stored internally as a unix timestamp. However, getAccessTokenExpiresAt()
converts it to a human-readable string (not even a DateTime object) before returning it to the caller, and the actual property is marked private so I can't grab it directly.
Checking if I need to refresh my token or not means comparing this expiration time to the current time. If I had a unix timestamp returned to me, I could just compare it to time()
. If it returned a DateTime object, I could compare it to date_create()
For now I'm working around it with something complicated like:
$access_expire_date = date_create_from_format( 'Y/m/d H:i:s', $accessTokenObj->getAccessTokenExpiresAt() )->getTimestamp();
which is a lot of effort just to get the value that's already stored in $accessTokenObj->accessTokenExpiresAt
but I can't access.
Obviously lots of people are already working around this and changing the return value would break people, so it would need a new accessor function to return it instead of fixing this one.
Same goes for refreshTokenExpiresAt