Reference documentation and code samples for the googleauth module Google::Auth::CredentialsLoader.
CredentialsLoader contains the behaviour used to locate and find default
credentials files on the file system.
Methods
.load_gcloud_project_id
defself.load_gcloud_project_id()
Finds project_id from gcloud CLI configuration
#from_env
deffrom_env(scope=nil,options={})
Creates an instance from the path specified in an environment
variable.
Parameters
scope(string|array|nil) — the scope(s) to access
options(Hash) —
Connection options. These may be used to configure
how OAuth tokens are retrieved, by providing a suitableFaraday::Connection. For example, if a connection proxy must be
used in the current network, you may provide a connection with
with the needed proxy options.
The following keys are recognized:
:default_connectionThe connection object to use.
:connection_builderAProcthat returns a connection.
Connection options. These may be used to configure
how OAuth tokens are retrieved, by providing a suitableFaraday::Connection. For example, if a connection proxy must be
used in the current network, you may provide a connection with
with the needed proxy options.
The following keys are recognized:
:default_connectionThe connection object to use.
:connection_builderAProcthat returns a connection.
Connection options. These may be used to configure
how OAuth tokens are retrieved, by providing a suitableFaraday::Connection. For example, if a connection proxy must be
used in the current network, you may provide a connection with
with the needed proxy options.
The following keys are recognized:
:default_connectionThe connection object to use.
:connection_builderAProcthat returns a connection.
[[["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,["# googleauth - Module Google::Auth::CredentialsLoader (v1.15.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.15.0 (latest)](/ruby/docs/reference/googleauth/latest/Google-Auth-CredentialsLoader)\n- [1.14.0](/ruby/docs/reference/googleauth/1.14.0/Google-Auth-CredentialsLoader)\n- [1.13.1](/ruby/docs/reference/googleauth/1.13.1/Google-Auth-CredentialsLoader)\n- [1.12.2](/ruby/docs/reference/googleauth/1.12.2/Google-Auth-CredentialsLoader) \nReference documentation and code samples for the googleauth module Google::Auth::CredentialsLoader.\n\nCredentialsLoader contains the behaviour used to locate and find default\ncredentials files on the file system.\n\nMethods\n-------\n\n### .load_gcloud_project_id\n\n def self.load_gcloud_project_id()\n\nFinds project_id from gcloud CLI configuration\n\n### #from_env\n\n def from_env(scope = nil, options = {})\n\nCreates an instance from the path specified in an environment\nvariable. \n**Parameters**\n\n- **scope** (string\\|array\\|nil) --- the scope(s) to access\n- **options** (Hash) ---\n\n Connection options. These may be used to configure\n how OAuth tokens are retrieved, by providing a suitable\n `Faraday::Connection`. For example, if a connection proxy must be\n used in the current network, you may provide a connection with\n with the needed proxy options.\n The following keys are recognized:\n - `:default_connection` The connection object to use.\n- `:connection_builder` A `Proc` that returns a connection. \n**Raises**\n\n- ([Google::Auth::InitializationError](./Google-Auth-InitializationError)) --- If the credentials file cannot be read\n\n### #from_system_default_path\n\n def from_system_default_path(scope = nil, options = {})\n\nCreates an instance from the system default path \n**Parameters**\n\n- **scope** (string\\|array\\|nil) --- the scope(s) to access\n- **options** (Hash) ---\n\n Connection options. These may be used to configure\n how OAuth tokens are retrieved, by providing a suitable\n `Faraday::Connection`. For example, if a connection proxy must be\n used in the current network, you may provide a connection with\n with the needed proxy options.\n The following keys are recognized:\n - `:default_connection` The connection object to use.\n- `:connection_builder` A `Proc` that returns a connection. \n**Raises**\n\n- ([Google::Auth::InitializationError](./Google-Auth-InitializationError)) --- If the credentials file cannot be read or is invalid\n\n### #from_well_known_path\n\n def from_well_known_path(scope = nil, options = {})\n\nCreates an instance from a well known path. \n**Parameters**\n\n- **scope** (string\\|array\\|nil) --- the scope(s) to access\n- **options** (Hash) ---\n\n Connection options. These may be used to configure\n how OAuth tokens are retrieved, by providing a suitable\n `Faraday::Connection`. For example, if a connection proxy must be\n used in the current network, you may provide a connection with\n with the needed proxy options.\n The following keys are recognized:\n - `:default_connection` The connection object to use.\n- `:connection_builder` A `Proc` that returns a connection. \n**Raises**\n\n- ([Google::Auth::InitializationError](./Google-Auth-InitializationError)) --- If the credentials file cannot be read\n\n### #make_creds\n\n def make_creds(*args)\n\nmake_creds proxies the construction of a credentials instance\n\n\n\u003cbr /\u003e\n\nBy default, it calls #new on the current class, but this behaviour can\nbe modified, allowing different instances to be created.\n\nConstants\n---------\n\n### ENV_VAR\n\n**value:**\"GOOGLE_APPLICATION_CREDENTIALS\".freeze\n\n### PRIVATE_KEY_VAR\n\n**value:**\"GOOGLE_PRIVATE_KEY\".freeze\n\n### CLIENT_EMAIL_VAR\n\n**value:**\"GOOGLE_CLIENT_EMAIL\".freeze\n\n### CLIENT_ID_VAR\n\n**value:**\"GOOGLE_CLIENT_ID\".freeze\n\n### CLIENT_SECRET_VAR\n\n**value:**\"GOOGLE_CLIENT_SECRET\".freeze\n\n### REFRESH_TOKEN_VAR\n\n**value:**\"GOOGLE_REFRESH_TOKEN\".freeze\n\n### ACCOUNT_TYPE_VAR\n\n**value:**\"GOOGLE_ACCOUNT_TYPE\".freeze\n\n### PROJECT_ID_VAR\n\n**value:**\"GOOGLE_PROJECT_ID\".freeze\n\n### AWS_REGION_VAR\n\n**value:**\"AWS_REGION\".freeze\n\n### AWS_DEFAULT_REGION_VAR\n\n**value:**\"AWS_DEFAULT_REGION\".freeze\n\n### AWS_ACCESS_KEY_ID_VAR\n\n**value:**\"AWS_ACCESS_KEY_ID\".freeze\n\n### AWS_SECRET_ACCESS_KEY_VAR\n\n**value:**\"AWS_SECRET_ACCESS_KEY\".freeze\n\n### AWS_SESSION_TOKEN_VAR\n\n**value:**\"AWS_SESSION_TOKEN\".freeze\n\n### GCLOUD_POSIX_COMMAND\n\n**value:**\"gcloud\".freeze\n\n### GCLOUD_WINDOWS_COMMAND\n\n**value:**\"gcloud.cmd\".freeze\n\n### GCLOUD_CONFIG_COMMAND\n\n**value:**\"config config-helper --format json --verbosity none --quiet\".freeze\n\n### CREDENTIALS_FILE_NAME\n\n**value:**\"application_default_credentials.json\".freeze\n\n### NOT_FOUND_ERROR\n\n**value:** \"Unable to read the credential file specified by #[ENV_VAR](/ruby/docs/reference/googleauth/latest/Google-Auth-CredentialsLoader#Google__Auth__CredentialsLoader__ENV_VAR \"Google::Auth::CredentialsLoader::ENV_VAR (constant)\")\".freeze\n\n### WELL_KNOWN_PATH\n\n**value:** \"gcloud/#[CREDENTIALS_FILE_NAME](/ruby/docs/reference/googleauth/latest/Google-Auth-CredentialsLoader#Google__Auth__CredentialsLoader__CREDENTIALS_FILE_NAME \"Google::Auth::CredentialsLoader::CREDENTIALS_FILE_NAME (constant)\")\".freeze\n\n### WELL_KNOWN_ERROR\n\n**value:**\"Unable to read the default credential file\".freeze\n\n### SYSTEM_DEFAULT_ERROR\n\n**value:**\"Unable to read the system default credential file\".freeze\n\n### CLOUD_SDK_CLIENT_ID\n\n**value:**\"764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.app\" \\\\\n\"s.googleusercontent.com\".freeze"]]