Method: Google::Auth::ServiceAccountJwtHeaderCredentials#initialize

Defined in:
lib/googleauth/service_account_jwt_header.rb

#initialize(options = {}) ⇒ ServiceAccountJwtHeaderCredentials

Initializes a ServiceAccountJwtHeaderCredentials.

Parameters:

  • json_key_io (IO)

    an IO from which the JSON key can be read

[View source]

60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/googleauth/service_account_jwt_header.rb', line 60

def initialize options = {}
  json_key_io = options[:json_key_io]
  if json_key_io
    @private_key, @issuer, @project_id, @quota_project_id, @universe_domain =
      self.class.read_json_key json_key_io
  else
    @private_key = options.key?(:private_key) ? options[:private_key] : ENV[CredentialsLoader::PRIVATE_KEY_VAR]
    @issuer = options.key?(:issuer) ? options[:issuer] : ENV[CredentialsLoader::CLIENT_EMAIL_VAR]
    @project_id = options.key?(:project_id) ? options[:project_id] : ENV[CredentialsLoader::PROJECT_ID_VAR]
    @quota_project_id = options[:quota_project_id] if options.key? :quota_project_id
    @universe_domain = options[:universe_domain] if options.key? :universe_domain
  end
  @universe_domain ||= "googleapis.com"
  @project_id ||= CredentialsLoader.load_gcloud_project_id
  @signing_key = OpenSSL::PKey::RSA.new @private_key
  @scope = options[:scope] if options.key? :scope
  @logger = options[:logger] if options.key? :logger
end