Module: Google::Auth::JsonKeyReader

Included in:
ServiceAccountCredentials, ServiceAccountJwtHeaderCredentials
Defined in:
lib/googleauth/json_key_reader.rb

Overview

JsonKeyReader contains the behaviour used to read private key and client email fields from the service account

Instance Method Summary collapse

Instance Method Details

#read_json_key(json_key_io) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/googleauth/json_key_reader.rb', line 22

def read_json_key json_key_io
  json_key = MultiJson.load json_key_io.read
  raise "missing client_email" unless json_key.key? "client_email"
  raise "missing private_key" unless json_key.key? "private_key"
  [
    json_key["private_key"],
    json_key["client_email"],
    json_key["project_id"],
    json_key["quota_project_id"],
    json_key["universe_domain"]
  ]
end