googleauth - Class Google::Auth::DefaultCredentials (v1.15.1)

Reference documentation and code samples for the googleauth class Google::Auth::DefaultCredentials.

DefaultCredentials is used to preload the credentials file, to determinewhich type of credentials should be loaded.

Inherits

  • Object

Methods

.determine_creds_class

defself.determine_creds_class(json_key_io=nil)->Array(Hash,Class)

Reads the input json and determines which creds class to use.

Parameter
  • json_key_io (IO, nil) — An optional IO object containing the JSON key.If nil, the credential type is determined from environment variables.
Returns
  • (Array(Hash, Class)) — The JSON key (or nil if from environment) and the credential class to use
Raises
  • (Google::Auth::InitializationError) — If the JSON is missing the type field or has an unsupported type,or if the environment variable is undefined or unsupported.

.make_creds

defself.make_creds(options={})->Google::Auth::Credentials

Override CredentialsLoader#make_creds to use the class determined byloading the json.

Important: If you accept a credential configuration (credentialJSON/File/Stream) from an external source for authentication to GoogleCloud, you must validate it before providing it to any Google API orlibrary. Providing an unvalidated credential configuration to GoogleAPIs can compromise the security of your systems and data. For moreinformation, refer toValidate credential configurations from externalsources.

Parameter
  • options (Hash) — Options for creating the credentials
Returns
Raises

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-10-30 UTC.