lib/googleauth/credentials.rb in googleauth-0.6.2 vs lib/googleauth/credentials.rb in googleauth-0.6.3

- old
+ new

@@ -29,19 +29,19 @@ require 'forwardable' require 'json' require 'signet/oauth_2/client' -require 'googleauth/default_credentials' +require 'googleauth/credentials_loader' module Google module Auth # This class is intended to be inherited by API-specific classes # which overrides the SCOPE constant. class Credentials - TOKEN_CREDENTIAL_URI = 'https://accounts.google.com/o/oauth2/token'.freeze - AUDIENCE = 'https://accounts.google.com/o/oauth2/token'.freeze + TOKEN_CREDENTIAL_URI = 'https://oauth2.googleapis.com/token'.freeze + AUDIENCE = 'https://oauth2.googleapis.com/token'.freeze SCOPE = [].freeze PATH_ENV_VARS = [].freeze JSON_ENV_VARS = [].freeze DEFAULT_PATHS = [].freeze @@ -66,29 +66,30 @@ verify_keyfile_exists! keyfile json = JSON.parse ::File.read(keyfile) json['scope'] ||= scope @client = init_client json end + CredentialsLoader.warn_if_cloud_sdk_credentials @client.client_id @client.fetch_access_token! end # Returns the default credentials checking, in this order, the path env # evironment variables, json environment variables, default paths. If the # previously stated locations do not contain keyfile information, # this method defaults to use the application default. def self.default(options = {}) scope = options[:scope] # First try to find keyfile file from environment variables. - client = from_path_vars(scope) + client = from_path_vars scope # Second try to find keyfile json from environment variables. - client ||= from_json_vars(scope) + client ||= from_json_vars scope # Third try to find keyfile file from known file paths. - client ||= from_default_paths(scope) + client ||= from_default_paths scope # Finally get instantiated client from Google::Auth - client ||= from_application_default(scope) + client ||= from_application_default scope client end def self.from_path_vars(scope) self::PATH_ENV_VARS