class Bcome::Driver::Gcp::Authentication::SignetServiceAccountClient

Public Class Methods

new(scopes, service_account_json_path) click to toggle source
# File lib/objects/driver/gcp/authentication/signet/service_account.rb, line 5
def initialize(scopes, service_account_json_path)
  @scopes = scopes
  @service_account_json_path = service_account_json_path
  raise ::Bcome::Exception::GcpAuthServiceAccountMissingCredentials, @service_account_json_path unless File.exist?(@service_account_json_path)
end

Public Instance Methods

authorize() click to toggle source
# File lib/objects/driver/gcp/authentication/signet/service_account.rb, line 16
def authorize
  @token ||= fetch_access_token
end
authorizer() click to toggle source
# File lib/objects/driver/gcp/authentication/signet/service_account.rb, line 20
def authorizer
  authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
    json_key_io: File.open(@service_account_json_path),
    scope: @scopes
  )
end
fetch_access_token(_options = {}) click to toggle source
# File lib/objects/driver/gcp/authentication/signet/service_account.rb, line 11
def fetch_access_token(_options = {})
  token = authorizer.fetch_access_token!
  token
end