Skip to content

Commit 218c164

Browse files
committed
https://github.com/magento/magento2/issues/24716
Not Able to set Rest API oAuth admin token expire in minutes or seconds. #24716
1 parent ea71192 commit 218c164

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

app/code/Magento/Integration/Helper/Oauth/Data.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,22 @@ public function getConsumerPostTimeout()
116116
/**
117117
* Get customer token lifetime from config.
118118
*
119-
* @return int hours
119+
* @return string hours
120120
*/
121121
public function getCustomerTokenLifetime()
122122
{
123-
$hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/customer');
124-
return $hours > 0 ? $hours : 0;
123+
$hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/customer');
124+
return is_numeric($hours) ? $hours : 0;
125125
}
126126

127127
/**
128128
* Get customer token lifetime from config.
129129
*
130-
* @return int hours
130+
* @return string hours
131131
*/
132132
public function getAdminTokenLifetime()
133133
{
134-
$hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/admin');
135-
return $hours > 0 ? $hours : 0;
134+
$hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/admin');
135+
return is_numeric($hours) ? $hours : 0;
136136
}
137137
}

app/code/Magento/Webapi/Model/Authorization/TokenUserContext.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private function isTokenExpired(Token $token): bool
137137
return false;
138138
}
139139

140-
if ($this->dateTime->strToTime($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) {
140+
if ($this->date->timestamp($token->getCreatedAt()) < ($this->date->gmtTimestamp() - $tokenTtl * 3600)) {
141141
return true;
142142
}
143143

0 commit comments

Comments
 (0)