Skip to content

Commit

Permalink
open up jsonKey to any credential class
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Oct 1, 2024
1 parent 22d07e2 commit 203722d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Credentials/ImpersonatedServiceAccountCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ class ImpersonatedServiceAccountCredentials extends CredentialsLoader implements
*
* @param string|string[] $scope The scope of the access request, expressed either as an
* array or as a space-delimited string.
* @param string|array<mixed> $jsonKey JSON credential file path or JSON credentials
* as an associative array.
* @param string|array<mixed> $jsonKey JSON credential file path or JSON array credentials {
* JSON credentials as an associative array.
*
* @type string $service_account_impersonation_url The URL to the service account
* @type string|FetchAuthTokenCredentials $source_credentials The source credentials to impersonate
* @type int $lifetime The lifetime of the impersonated credentials
* @type string[] $delegates The delegates to impersonate
* }
*/
public function __construct(
$scope,
Expand Down Expand Up @@ -90,10 +96,9 @@ public function __construct(
$this->serviceAccountImpersonationUrl
);

$this->sourceCredentials = new UserRefreshCredentials(
$scope,
$jsonKey['source_credentials']
);
$this->sourceCredentials = $jsonKey['source_credentials'] instanceof FetchAuthTokenCredentials

Check failure on line 99 in src/Credentials/ImpersonatedServiceAccountCredentials.php

View workflow job for this annotation

GitHub Actions / PHPStan Static Analysis / PHPStan Static Analysis

Class Google\Auth\Credentials\FetchAuthTokenCredentials not found.

Check failure on line 99 in src/Credentials/ImpersonatedServiceAccountCredentials.php

View workflow job for this annotation

GitHub Actions / PHPStan Static Analysis / PHPStan Static Analysis

Property Google\Auth\Credentials\ImpersonatedServiceAccountCredentials::$sourceCredentials (Google\Auth\Credentials\UserRefreshCredentials) does not accept Google\Auth\Credentials\ExternalAccountCredentials|Google\Auth\Credentials\FetchAuthTokenCredentials|Google\Auth\Credentials\ImpersonatedServiceAccountCredentials|Google\Auth\Credentials\ServiceAccountCredentials|Google\Auth\Credentials\UserRefreshCredentials.
? $jsonKey['source_credentials']
: CredentialsLoader::makeCredentials($scope, $jsonKey['source_credentials']);
}

/**
Expand Down

0 comments on commit 203722d

Please sign in to comment.