Class: Fastlane::Checks::Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane/plugin/checks/helper/credentials.rb

Instance Method Summary collapse

Constructor Details

#initialize(key_file_path: nil) ⇒ Credentials

Returns a new instance of Credentials.



22
23
24
# File 'lib/fastlane/plugin/checks/helper/credentials.rb', line 22

def initialize(key_file_path: nil)
  @key_file_path = key_file_path
end

Instance Method Details

#get_google_credential(scopes) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fastlane/plugin/checks/helper/credentials.rb', line 26

def get_google_credential(scopes)
  File.open(File.expand_path(@key_file_path), "r") do |file|
    options = {
      json_key_io: file,
      scope: scopes
    }
    begin
      return Google::Auth::ServiceAccountCredentials.make_creds(options)
    rescue StandardError => e
      UI.abort_with_message!("Failed to read service account file: #{e.message}")
    end
  end
end