Skip to content

Commit 35b4874

Browse files
committed
Merge branch 'main' into trust-boundaries
2 parents 6a89ee3 + 870c17e commit 35b4874

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
* [feat]: add support for Firebase v6.0 (#391)
44

5+
## [1.50.1](https://github.com/googleapis/google-auth-library-php/compare/v1.50.0...v1.50.1) (2026-03-18)
6+
7+
8+
### Bug Fixes
9+
10+
* ImpersonatedCredentials getLastReceivedToken returns correct token ([#655](https://github.com/googleapis/google-auth-library-php/issues/655)) ([a4fe69c](https://github.com/googleapis/google-auth-library-php/commit/a4fe69c11c0c8bbe78e33eb1433c6dbcec72af2a))
11+
* Support psr/log 2 ([#654](https://github.com/googleapis/google-auth-library-php/issues/654)) ([4b746b8](https://github.com/googleapis/google-auth-library-php/commit/4b746b844ff60d86c6dcc940eb250a0753919181))
12+
513
## [1.50.0](https://github.com/googleapis/google-auth-library-php/compare/v1.49.0...v1.50.0) (2026-01-08)
614

715

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.50.0
1+
1.50.1

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"guzzlehttp/psr7": "^2.4.5",
1616
"psr/http-message": "^1.1||^2.0",
1717
"psr/cache": "^2.0||^3.0",
18-
"psr/log": "^3.0"
18+
"psr/log": "^2.0||^3.0"
1919
},
2020
"require-dev": {
2121
"guzzlehttp/promises": "^2.0",

src/Credentials/ImpersonatedServiceAccountCredentials.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ class ImpersonatedServiceAccountCredentials extends CredentialsLoader implements
7878

7979
private int $lifetime;
8080

81+
/**
82+
* @var array<mixed>|null
83+
*/
84+
protected array|null $lastReceivedToken = null;
85+
8186
/**
8287
* Instantiate an instance of ImpersonatedServiceAccountCredentials from a credentials file that
8388
* has be created with the --impersonate-service-account flag.
@@ -263,7 +268,7 @@ public function fetchAuthToken(?callable $httpHandler = null)
263268
$response = $httpHandler($request);
264269
$body = json_decode((string) $response->getBody(), true);
265270

266-
return match ($this->isIdTokenRequest()) {
271+
return $this->lastReceivedToken = match ($this->isIdTokenRequest()) {
267272
true => ['id_token' => $body['token']],
268273
false => [
269274
'access_token' => $body['accessToken'],
@@ -290,7 +295,7 @@ public function getCacheKey()
290295
*/
291296
public function getLastReceivedToken()
292297
{
293-
return $this->sourceCredentials->getLastReceivedToken();
298+
return $this->lastReceivedToken;
294299
}
295300

296301
protected function getCredType(): string

tests/Credentials/ImpersonatedServiceAccountCredentialsTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public function testGetAccessTokenWithServiceAccountAndUserRefreshCredentials(ar
186186
$token = $creds->fetchAuthToken($httpHandler);
187187
$this->assertEquals('test-impersonated-access-token', $token['access_token']);
188188
$this->assertEquals(2, $requestCount);
189+
$this->assertEquals($token, $creds->getLastReceivedToken());
189190
}
190191

191192
/**
@@ -225,6 +226,7 @@ public function testGetAccessTokenWithExternalAccountCredentials()
225226
$token = $creds->fetchAuthToken($httpHandler);
226227
$this->assertEquals('test-impersonated-access-token', $token['access_token']);
227228
$this->assertEquals(3, $requestCount);
229+
$this->assertEquals($token, $creds->getLastReceivedToken());
228230
}
229231

230232
/**
@@ -266,6 +268,7 @@ public function testGetIdTokenWithServiceAccountAndUserRefreshCredentials(array
266268
$token = $creds->fetchAuthToken($httpHandler);
267269
$this->assertEquals('test-impersonated-id-token', $token['id_token']);
268270
$this->assertEquals(2, $requestCount);
271+
$this->assertEquals($token, $creds->getLastReceivedToken());
269272
}
270273

271274
public function provideAuthTokenJson()
@@ -307,6 +310,7 @@ public function testGetIdTokenWithServiceAccountCredentialsAndUniverseDomain()
307310
$creds = new ImpersonatedServiceAccountCredentials(null, $json, self::TARGET_AUDIENCE);
308311
$token = $creds->fetchAuthToken($httpHandler);
309312
$this->assertEquals('test-impersonated-id-token', $token['id_token']);
313+
$this->assertEquals($token, $creds->getLastReceivedToken());
310314
}
311315

312316
/**
@@ -378,6 +382,7 @@ public function testGetIdTokenWithExternalAccountCredentials(?string $universeDo
378382
$token = $creds->fetchAuthToken($httpHandler);
379383
$this->assertEquals('test-impersonated-id-token', $token['id_token']);
380384
$this->assertEquals(3, $requestCount);
385+
$this->assertEquals($token, $creds->getLastReceivedToken());
381386
}
382387

383388
/**
@@ -416,6 +421,7 @@ public function testGetIdTokenWithArbitraryCredentials(?string $universeDomain =
416421

417422
$token = $creds->fetchAuthToken($httpHandler);
418423
$this->assertEquals('test-impersonated-id-token', $token['id_token']);
424+
$this->assertEquals($token, $creds->getLastReceivedToken());
419425
}
420426

421427
public function provideUniverseDomain()
@@ -455,6 +461,7 @@ public function testGetAccessTokenWithArbitraryCredentials()
455461

456462
$token = $creds->fetchAuthToken($httpHandler);
457463
$this->assertEquals('test-impersonated-access-token', $token['access_token']);
464+
$this->assertEquals($token, $creds->getLastReceivedToken());
458465
}
459466

460467
public function testIdTokenWithAuthTokenMiddleware()

0 commit comments

Comments
 (0)