Method: Supply::AbstractGoogleServiceClient.service_account_authentication

Defined in:
supply/lib/supply/client.rb

.service_account_authentication(params: nil) ⇒ Object

Supply authentication file



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'supply/lib/supply/client.rb', line 23

def self.(params: nil)
  unless params[:json_key] || params[:json_key_data]
    if UI.interactive?
      UI.important("To not be asked about this value, you can specify it using 'json_key'")
      json_key_path = UI.input("The service account json file used to authenticate with Google: ")
      json_key_path = File.expand_path(json_key_path)

      UI.user_error!("Could not find service account json file at path '#{json_key_path}'") unless File.exist?(json_key_path)
      params[:json_key] = json_key_path
    else
      UI.user_error!("Could not load Google authentication. Make sure it has been added as an environment variable in 'json_key' or 'json_key_data'")
    end
  end

  if params[:json_key]
     = File.open(File.expand_path(params[:json_key]))
  elsif params[:json_key_data]
     = StringIO.new(params[:json_key_data])
  end

  
end