Module: Google::Auth

Defined in:
lib/googleauth.rb,
lib/googleauth/version.rb,
lib/googleauth/user_refresh.rb,
lib/googleauth/compute_engine.rb,
lib/googleauth/service_account.rb,
lib/googleauth/credentials_loader.rb

Overview

Module Auth provides classes that provide Google-specific authorization used to access Google APIs.

Defined Under Namespace

Modules: CredentialsLoader Classes: DefaultCredentials, GCECredentials, ServiceAccountCredentials, UserRefreshCredentials

Constant Summary collapse

NOT_FOUND_ERROR =
"Could not load the default credentials. Browse to\nhttps://developers.google.com/accounts/docs/application-default-credentials\nfor more information\n"
VERSION =
'0.2.0'

Class Method Summary collapse

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.



83
84
85
86
87
88
89
90
# File 'lib/googleauth.rb', line 83

def get_application_default(scope, options = {})
  creds = DefaultCredentials.from_env(scope)
  return creds unless creds.nil?
  creds = DefaultCredentials.from_well_known_path(scope)
  return creds unless creds.nil?
  fail NOT_FOUND_ERROR unless GCECredentials.on_gce?(options)
  GCECredentials.new
end