Reference documentation and code samples for the Google Auth Library Client class CredentialsLoader.
CredentialsLoader contains the behaviour used to locate and find default
credentials files on the file system.
Namespace
Google \ Auth
Methods
getUniverseDomain
Get the universe domain from the credential. Defaults to "googleapis.com"
for all credential types which do not support universe domain.
Returns
Type
Description
string
static::fromEnv
Load a JSON key from the path specified in the environment.
Load a JSON key from the path specified in the environment
variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
GOOGLE_APPLICATION_CREDENTIALS is not specified.
Important: If you accept a credential configuration (credential JSON/File/Stream) from an
external source for authentication to Google Cloud Platform, you must validate it before
providing it to any Google API or library. Providing an unvalidated credential configuration to
Google APIs can compromise the security of your systems and data. For more informationhttps://cloud.google.com/docs/authentication/external/externally-sourced-credentials
Parameters
Name
Description
scope
string|string[]
the scope of the access request, expressed
either as an Array or as a space-delimited String.
jsonKey
array
the JSON credentials.
defaultScope
string|string[]
The default scope to use if no
user-defined scopes exist, expressed either as an Array or as a
space-delimited string.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Google Auth Library Client - Class CredentialsLoader (1.47.1)\n\nVersion latestkeyboard_arrow_down\n\n- [1.47.1 (latest)](/php/docs/reference/auth/latest/CredentialsLoader)\n- [1.47.0](/php/docs/reference/auth/1.47.0/CredentialsLoader)\n- [1.46.0](/php/docs/reference/auth/1.46.0/CredentialsLoader)\n- [1.45.2](/php/docs/reference/auth/1.45.2/CredentialsLoader) \nReference documentation and code samples for the Google Auth Library Client class CredentialsLoader.\n\nCredentialsLoader contains the behaviour used to locate and find default\ncredentials files on the file system.\n\nNamespace\n---------\n\nGoogle \\\\ Auth\n\nMethods\n-------\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.\n\n### static::fromEnv\n\nLoad a JSON key from the path specified in the environment.\n\nLoad a JSON key from the path specified in the environment\nvariable GOOGLE_APPLICATION_CREDENTIALS. Return null if\nGOOGLE_APPLICATION_CREDENTIALS is not specified.\n\n### static::fromWellKnownFile\n\nLoad a JSON key from a well known path.\n\nThe well known path is OS dependent:\n\n- windows: %APPDATA%/gcloud/application_default_credentials.json\n- others: $HOME/.config/gcloud/application_default_credentials.json\n\nIf the file does not exist, this returns null.\n\n### static::makeCredentials\n\nCreate a new Credentials instance.\n\n**Important** : If you accept a credential configuration (credential JSON/File/Stream) from an\nexternal source for authentication to Google Cloud Platform, you must validate it before\nproviding it to any Google API or library. Providing an unvalidated credential configuration to\nGoogle APIs can compromise the security of your systems and data. For more information\n\u003chttps://cloud.google.com/docs/authentication/external/externally-sourced-credentials\u003e\n\n### static::makeHttpClient\n\nCreate an authorized HTTP Client from an instance of FetchAuthTokenInterface.\n\n### static::makeInsecureCredentials\n\nCreate a new instance of InsecureCredentials.\n\n### static::quotaProjectFromEnv\n\nFetch a quota project from the environment variable\nGOOGLE_CLOUD_QUOTA_PROJECT. Return null if\nGOOGLE_CLOUD_QUOTA_PROJECT is not specified.\n\n### static::getDefaultClientCertSource\n\nGets a callable which returns the default device certification.\n\n### static::shouldLoadClientCertSource\n\nDetermines whether or not the default device certificate should be loaded.\n\nConstants\n---------\n\n### TOKEN_CREDENTIAL_URI\n\n Value: 'https://oauth2.googleapis.com/token'\n\n### ENV_VAR\n\n Value: 'GOOGLE_APPLICATION_CREDENTIALS'\n\n### QUOTA_PROJECT_ENV_VAR\n\n Value: 'GOOGLE_CLOUD_QUOTA_PROJECT'\n\n### WELL_KNOWN_PATH\n\n Value: 'gcloud/application_default_credentials.json'\n\n### NON_WINDOWS_WELL_KNOWN_PATH_BASE\n\n Value: '.config'\n\n### MTLS_WELL_KNOWN_PATH\n\n Value: '.secureConnect/context_aware_metadata.json'\n\n### MTLS_CERT_ENV_VAR\n\n Value: 'GOOGLE_API_USE_CLIENT_CERTIFICATE'"]]