If supplied, scope is used to create the credentials instance, when it can
be applied. E.g, on google compute engine and for user credentials the
scope is ignored.
Parameters
scope(string|array|nil) — the scope(s) to access
options(Hash) —
Connection options. These may be used to configure
theFaraday::Connectionused for outgoing HTTP requests. 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 for token
refresh requests.
:connection_builderAProcthat creates and returns a
connection to use for token refresh requests.
:connectionThe connection to use to determine whether GCE
metadata credentials are available.
value:<<~ERROR.freeze
Error code 404 trying to get security access token
from Compute Engine metadata for the default service account. This
may be because the virtual machine instance does not have permission
scopes specified.
ERROR
UNEXPECTED_ERROR_SUFFIX
value:<<~ERROR.freeze
trying to get security access token from Compute Engine metadata for
the default service account
ERROR
[[["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 (v1.15.0)\n\nVersion latestkeyboard_arrow_down\n\n- [1.15.0 (latest)](/ruby/docs/reference/googleauth/latest/Google-Auth)\n- [1.14.0](/ruby/docs/reference/googleauth/1.14.0/Google-Auth)\n- [1.13.1](/ruby/docs/reference/googleauth/1.13.1/Google-Auth)\n- [1.12.2](/ruby/docs/reference/googleauth/1.12.2/Google-Auth) \nReference documentation and code samples for the googleauth module Google::Auth.\n\nModule Auth provides classes that provide Google-specific authorization used to access Google APIs.\n\nMethods\n-------\n\n### .get_application_default\n\n def self.get_application_default(scope = nil, options = {})\n\nObtains the default credentials implementation to use in this\nenvironment.\n\n\nUse this to obtain the Application Default Credentials for accessing\nGoogle APIs. Application Default Credentials are described in detail\nat \u003chttps://cloud.google.com/docs/authentication/production\u003e.\n\n\u003cbr /\u003e\n\nIf supplied, scope is used to create the credentials instance, when it can\nbe applied. E.g, on google compute engine and for user credentials the\nscope is ignored. \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 the `Faraday::Connection` used for outgoing HTTP requests. For\n example, if a connection proxy must be used in the current network,\n you may provide a connection with with the needed proxy options.\n The following keys are recognized:\n - `:default_connection` The connection object to use for token refresh requests.\n - `:connection_builder` A `Proc` that creates and returns a connection to use for token refresh requests.\n- `:connection` The connection to use to determine whether GCE metadata credentials are available. \n**Raises**\n\n- ([Google::Auth::InitializationError](./Google-Auth-InitializationError)) --- If the credentials cannot be found\n\nConstants\n---------\n\n### VERSION\n\n**value:**\"1.15.0\".freeze\n\n### NO_METADATA_SERVER_ERROR\n\n**value:**\\\u003c\\\u003c\\~ERROR.freeze\nError code 404 trying to get security access token\nfrom Compute Engine metadata for the default service account. This\nmay be because the virtual machine instance does not have permission\nscopes specified.\nERROR\n\n### UNEXPECTED_ERROR_SUFFIX\n\n**value:**\\\u003c\\\u003c\\~ERROR.freeze\ntrying to get security access token from Compute Engine metadata for\nthe default service account\nERROR\n\n### NOT_FOUND_ERROR\n\n**value:** \\\u003c\\\u003c\\~ERROR_MESSAGE.freeze\nYour credentials were not found. To set up Application Default\nCredentials for your environment, see\n\u003chttps://cloud.google.com/docs/authentication/external/set-up-adc\u003e\nERROR_MESSAGE"]]