Skip to content

Commit d82197b

Browse files
committed
Add support for admin WebAPI token refresh
1 parent 7836c00 commit d82197b

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Diff for: etc/config/.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,8 @@ BROWSER_LOG_BLOCKLIST=other
7272

7373
#*** Elastic Search version used for test ***#
7474
ELASTICSEARCH_VERSION=7
75+
76+
#*** Lifetime (in seconds) of Magento Admin WebAPI Token; if token is older than this value a refresh attempt will be made just before the next WebAPI call ***#
77+
#MAGENTO_ADMIN_WEBAPI_TOKEN_LIFETIME=10800
78+
7579
#*** End of .env ***#

Diff for: src/Magento/FunctionalTestingFramework/DataTransport/Auth/WebApiAuth.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public static function getAdminToken($username = null, $password = null)
7070
}
7171

7272
if (isset(self::$adminAuthTokens[$login])) {
73-
$threeHours = 60 * 60 * 3;
74-
$isTokenAboutToExpire = time() - self::$adminAuthTokenTimestamps[$login] > $threeHours;
73+
$tokenLifetime = getenv('MAGENTO_ADMIN_WEBAPI_TOKEN_LIFETIME');
74+
75+
$isTokenAboutToExpire = $tokenLifetime && time() - self::$adminAuthTokenTimestamps[$login] > $tokenLifetime;
7576

7677
if (!$isTokenAboutToExpire) {
7778
return self::$adminAuthTokens[$login];

0 commit comments

Comments
 (0)