Class: Remocon::Command::GetToken

Inherits:
Object
  • Object
show all
Defined in:
lib/remocon/command/get_token_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ GetToken

Returns a new instance of GetToken.



8
9
10
11
# File 'lib/remocon/command/get_token_command.rb', line 8

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

Instance Attribute Details

#cmd_optsObject (readonly)

Returns the value of attribute cmd_opts.



6
7
8
# File 'lib/remocon/command/get_token_command.rb', line 6

def cmd_opts
  @cmd_opts
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/remocon/command/get_token_command.rb', line 6

def config
  @config
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/remocon/command/get_token_command.rb', line 13

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