oauth2-server-php
oauth2-server-php copied to clipboard
[VERY SERIOUS] invalid expiry time for token
@bshaffer
I got this error: Invalid datetime format: 1292 Incorrect datetime value: '2016-10-02 02:56:02' for column 'expires'
[Redacted Stack trace]
ResponseType/AccessToken.php(84)
ResponseType\AccessToken->createAccessToken(...
The [MySQL] expires
column for both access_tokens
and authorization_codes
tables is timestamp
.
I believe the code that attempted to put the date is:
$this->config['access_lifetime'] ? time() + $this->config['access_lifetime'] : null
into setAccessToken($access_token, $client_id, $user_id, $expires, $scope = null)
(for $expires).
My 2 cents worth is that it generated an invalid daylight savings time. Otherwise the value seems totally fine to me.
This is the top statement of log: [2016-10-02 01:56:02] production.ERROR: PDOException: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2016-10-02 02:56:02' for column 'expires' at row 1 in XXX
It looks like server's time is 1:56:02.
I'm not sure what access_lifetime
was at the time but I suspect it was 3600
(1 hour).
time() + $this->config['access_lifetime']
returns a unix timestamp.
$expires = date('Y-m-d H:i:s', $expires);
Somehow PHP attempts to convert it to a Y-m-d H:i:s
format incorrecty (?).
Hi, did you solve this issue? Please tell us how could you fix this error.
I didn't fix the issue.
We faced similar issue, and we changed the expires
column type to DATETIME, and now it seems ok.
I'm just waiting for @bshaffer opinion on the matter because he may have a reason for timestamp
Just ran into this issue myself. It happened because I hadn't set the expiry for id_lifetime
/access_lifetime
. Set those and the error vanished