Reference documentation and code samples for the Google Auth Library Client class ImpersonatedServiceAccountCredentials.
CredentialsLoader contains the behaviour used to locate and find default
credentials files on the file system.
Namespace
Google \ Auth \ Credentials
Methods
__construct
Instantiate an instance of ImpersonatedServiceAccountCredentials from a credentials file that
has be created with the --impersonate-service-account flag.
Parameters
Name
Description
scope
string|string[]|null
The scope of the access request, expressed either as an
array or as a space-delimited string.
jsonKey
string|array
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|FetchAuthTokenInterface $source_credentials The source credentials to impersonate
@type int $lifetime The lifetime of the impersonated credentials
@type string[] $delegates The delegates to impersonate
}
targetAudience
string|null
The audience to request an ID token.
getClientName
Get the client name from the keyfile
In this implementation, it will return the issuers email from the oauth token.
Parameter
Name
Description
unusedHttpHandler
callable|null
not used by this credentials type.
Returns
Type
Description
string
Token issuer email
fetchAuthToken
Fetches the auth tokens based on the current state.
Parameter
Name
Description
httpHandler
callable|null
Returns
Type
Description
array
{
A set of auth related metadata, containing the following
@type string $access_token
@type int $expires_in
@type string $scope
@type string $token_type
@type string $id_token
}
getCacheKey
Returns the Cache Key for the credentials
The cache key is the same as the UserRefreshCredentials class
Returns
Type
Description
string
getLastReceivedToken
Returns an associative array with the token and
expiration time.
Returns
Type
Description
array
getUniverseDomain
Get the universe domain from the credential. Defaults to "googleapis.com"
for all credential types which do not support universe domain.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Google Auth Library Client - Class ImpersonatedServiceAccountCredentials (1.47.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.47.1 (latest)](/php/docs/reference/auth/latest/Credentials.ImpersonatedServiceAccountCredentials)\n- [1.47.0](/php/docs/reference/auth/1.47.0/Credentials.ImpersonatedServiceAccountCredentials)\n- [1.46.0](/php/docs/reference/auth/1.46.0/Credentials.ImpersonatedServiceAccountCredentials)\n- [1.45.2](/php/docs/reference/auth/1.45.2/Credentials.ImpersonatedServiceAccountCredentials) \nReference documentation and code samples for the Google Auth Library Client class ImpersonatedServiceAccountCredentials.\n\nCredentialsLoader contains the behaviour used to locate and find default\ncredentials files on the file system.\n\nNamespace\n---------\n\nGoogle \\\\ Auth \\\\ Credentials\n\nMethods\n-------\n\n### __construct\n\nInstantiate an instance of ImpersonatedServiceAccountCredentials from a credentials file that\nhas be created with the --impersonate-service-account flag.\n\n### getClientName\n\nGet the client name from the keyfile\n\nIn this implementation, it will return the issuers email from the oauth token.\n\n### fetchAuthToken\n\nFetches the auth tokens based on the current state.\n\n### getCacheKey\n\nReturns the Cache Key for the credentials\nThe cache key is the same as the UserRefreshCredentials class\n\n### getLastReceivedToken\n\nReturns an associative array with the token and\nexpiration time.\n\n### getUniverseDomain\n\nGet the universe domain from the credential. Defaults to \"googleapis.com\"\nfor all credential types which do not support universe domain."]]