class Armrest::Api::Auth::CLI

Public Instance Methods

creds() click to toggle source
# File lib/armrest/api/auth/cli.rb, line 20
def creds
  data = get_access_token
  data.deep_transform_keys { |k| k.underscore } # to normalize the structure to the other classes
end
get_access_token() click to toggle source

Looks like az account get-access-token caches the toke in ~/.azure/accessTokens.json and will update it only when it expires. So dont think we need to handle caching

# File lib/armrest/api/auth/cli.rb, line 27
def get_access_token
  command = "az account get-access-token -o json --resource #{resource}"
  logger.debug "command: #{command}"
  out = `#{command}`
  JSON.load(out)
rescue
  raise CliError, 'Error acquiring token from the Azure az CLI'
end