lib/googleauth/credentials.rb in googleauth-0.15.1 vs lib/googleauth/credentials.rb in googleauth-0.16.0

- old
+ new

@@ -367,13 +367,14 @@ # def initialize keyfile, options = {} verify_keyfile_provided! keyfile @project_id = options["project_id"] || options["project"] @quota_project_id = options["quota_project_id"] - if keyfile.is_a? Signet::OAuth2::Client + case keyfile + when Signet::OAuth2::Client update_from_signet keyfile - elsif keyfile.is_a? Hash + when Hash update_from_hash keyfile, options else update_from_filepath keyfile, options end CredentialsLoader.warn_if_cloud_sdk_credentials @client.client_id @@ -501,13 +502,15 @@ .configure_connection(connection_options) end # returns a new Hash with string keys instead of symbol keys. def stringify_hash_keys hash - Hash[hash.map { |k, v| [k.to_s, v] }] + hash.to_h.transform_keys(&:to_s) end + # rubocop:disable Metrics/AbcSize + def client_options options # Keyfile options have higher priority over constructor defaults options["token_credential_uri"] ||= self.class.token_credential_uri options["audience"] ||= self.class.audience options["scope"] ||= self.class.scope @@ -524,9 +527,11 @@ scope: (needs_scope ? Array(options["scope"]) : nil), target_audience: options["target_audience"], issuer: options["client_email"], signing_key: OpenSSL::PKey::RSA.new(options["private_key"]) } end + + # rubocop:enable Metrics/AbcSize def update_from_signet client @project_id ||= client.project_id if client.respond_to? :project_id @quota_project_id ||= client.quota_project_id if client.respond_to? :quota_project_id @client = client