Sha256: 68b870519647d07dffd369fe5dc715992b15d14544dc8e5003114e5e7f34a823

Contents?: true

Size: 843 Bytes

Versions: 9

Compression:

Stored size: 843 Bytes

Contents

# frozen_string_literal: true

module Remocon
  module Command
    class GetToken
      attr_reader :config, :cmd_opts

      def initialize(opts)
        @config = Remocon::Config.new(opts)
        @cmd_opts = {}
      end

      def run
        validate_options

        authorizer = Google::Auth::ServiceAccountCredentials.make_creds(
          json_key_io: File.open(config.service_json_file_path),
          scope: "https://www.googleapis.com/auth/firebase.remoteconfig"
        )

        authorizer.fetch_access_token!
        STDOUT.puts authorizer.access_token

        authorizer.access_token
      end

      private

      def validate_options
        raise ValidationError, "a service account json file is not found" if config.service_json_file_path.nil? || !File.exist?(config.service_json_file_path)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
remocon-0.5.1 lib/remocon/command/get_token_command.rb
remocon-0.5.0 lib/remocon/command/get_token_command.rb
remocon-0.4.4 lib/remocon/command/get_token_command.rb
remocon-0.4.3 lib/remocon/command/get_token_command.rb
remocon-0.4.2 lib/remocon/command/get_token_command.rb
remocon-0.4.1 lib/remocon/command/get_token_command.rb
remocon-0.4.0 lib/remocon/command/get_token_command.rb
remocon-0.4.0.pre.1 lib/remocon/command/get_token_command.rb
remocon-0.3.1 lib/remocon/command/get_token_command.rb