From 274d56aa40d29633ef28b9d0470e31436ad9509c Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Wed, 11 Dec 2019 19:44:55 +0300 Subject: [PATCH] Set expires_in value for issue access token response --- api/modules/oauth/models/OauthProcess.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/modules/oauth/models/OauthProcess.php b/api/modules/oauth/models/OauthProcess.php index be0dfc3..8da56f7 100644 --- a/api/modules/oauth/models/OauthProcess.php +++ b/api/modules/oauth/models/OauthProcess.php @@ -175,6 +175,14 @@ class OauthProcess { $result['refresh_token'] = $result['access_token']; } + if (($result['expires_in'] ?? 0) <= 0) { + // Since some of our clients use this field to understand how long the token will live, + // we have to give it some value. The tokens with zero lifetime don't expire + // but in order not to break the clients storing the value as integer on 32-bit systems, + // let's calculate the value based on the unsigned maximum for this type + $result['expires_in'] = 2 ** 31 - time(); + } + Yii::$app->statsd->inc("oauth.issueToken_client.{$clientId}"); Yii::$app->statsd->inc("oauth.issueToken_{$grantType}.success"); } catch (OAuthServerException $e) {