Reference documentation and code samples for the Google Auth Library Client class UserRefreshCredentials.
Authenticates requests using User Refresh credentials.
This class allows authorizing requests from user refresh tokens.
This the end of the result of a 3LO flow. E.g, the end result of
'gcloud auth login' saves a file with these contents in well known
location
Namespace
Google \ Auth \ Credentials
Methods
__construct
Create a new UserRefreshCredentials.
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 credentials
as an associative array
targetAudience
string|null
The audience for the ID token.
fetchAuthToken
Fetches the auth tokens based on the current state.
Parameters
Name
Description
httpHandler
callable|null
headers
array
[optional] Metrics headers to be inserted
into the token endpoint request present.
This could be passed from ImersonatedServiceAccountCredentials as it uses
UserRefreshCredentials as source credentials.
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
Return the Cache Key for the credentials.
The format for the Cache key is one of the following:
ClientId.Scope
ClientId.Audience
Returns
Type
Description
string
getLastReceivedToken
Returns an associative array with the token and
expiration time.
Returns
Type
Description
array
getQuotaProject
Get the quota project used for this API request
Returns
Type
Description
string|null
getGrantedScope
Get the granted scopes (if they exist) for the last fetched token.
[[["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 UserRefreshCredentials (1.47.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.47.1 (latest)](/php/docs/reference/auth/latest/Credentials.UserRefreshCredentials)\n- [1.47.0](/php/docs/reference/auth/1.47.0/Credentials.UserRefreshCredentials)\n- [1.46.0](/php/docs/reference/auth/1.46.0/Credentials.UserRefreshCredentials)\n- [1.45.2](/php/docs/reference/auth/1.45.2/Credentials.UserRefreshCredentials) \nReference documentation and code samples for the Google Auth Library Client class UserRefreshCredentials.\n\nAuthenticates requests using User Refresh credentials.\n\nThis class allows authorizing requests from user refresh tokens.\n\nThis the end of the result of a 3LO flow. E.g, the end result of\n'gcloud auth login' saves a file with these contents in well known\nlocation\n\nNamespace\n---------\n\nGoogle \\\\ Auth \\\\ Credentials\n\nMethods\n-------\n\n### __construct\n\nCreate a new UserRefreshCredentials.\n\n### fetchAuthToken\n\nFetches the auth tokens based on the current state.\n\n### getCacheKey\n\nReturn the Cache Key for the credentials.\n\nThe format for the Cache key is one of the following:\nClientId.Scope\nClientId.Audience\n\n### getLastReceivedToken\n\nReturns an associative array with the token and\nexpiration time.\n\n### getQuotaProject\n\nGet the quota project used for this API request\n\n### getGrantedScope\n\nGet the granted scopes (if they exist) for the last fetched token."]]