Module: Google::Auth
- Defined in:
- lib/googleauth.rb,
lib/googleauth/version.rb,
lib/googleauth/compute_engine.rb,
lib/googleauth/service_account.rb
Overview
Module Auth provides classes that provide Google-specific authorization used to access Google APIs.
Defined Under Namespace
Classes: GCECredentials, ServiceAccountCredentials
Constant Summary collapse
- NOT_FOUND_ERROR =
<<END Could not load the default credentials. Browse to https://developers.google.com/accounts/docs/application-default-credentials for more information END
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.get_application_default(scope, options = {}) ⇒ Object
Obtains the default credentials implementation to use in this environment.
Class Method Details
.get_application_default(scope, options = {}) ⇒ Object
Obtains the default credentials implementation to use in this environment.
Use this to obtain the Application Default Credentials for accessing Google APIs. Application Default Credentials are described in detail at goo.gl/IUuyuX.
If supplied, scope is used to create the credentials instance, when it can applied. E.g, on compute engine, the scope is ignored.
55 56 57 58 59 60 61 62 |
# File 'lib/googleauth.rb', line 55 def get_application_default(scope, = {}) creds = ServiceAccountCredentials.from_env(scope) return creds unless creds.nil? creds = ServiceAccountCredentials.from_well_known_path(scope) return creds unless creds.nil? fail NOT_FOUND_ERROR unless GCECredentials.on_gce?() GCECredentials.new end |