oauth2-server-php icon indicating copy to clipboard operation
oauth2-server-php copied to clipboard

[VERY SERIOUS] invalid expiry time for token

Open pjebs opened this issue 8 years ago • 7 comments

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

pjebs avatar Feb 12 '17 23:02 pjebs

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

pjebs avatar Feb 12 '17 23:02 pjebs

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 (?).

pjebs avatar Feb 12 '17 23:02 pjebs

Hi, did you solve this issue? Please tell us how could you fix this error.

nash4ever avatar Feb 26 '17 17:02 nash4ever

I didn't fix the issue.

pjebs avatar Feb 27 '17 11:02 pjebs

We faced similar issue, and we changed the expires column type to DATETIME, and now it seems ok.

nash4ever avatar Feb 27 '17 11:02 nash4ever

I'm just waiting for @bshaffer opinion on the matter because he may have a reason for timestamp

pjebs avatar Feb 27 '17 21:02 pjebs

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

JAY6390 avatar Oct 17 '20 00:10 JAY6390