Class: Armrest::Api::Auth::CLI
Defined Under Namespace
Constant Summary
Constants inherited from Base
Base::HTTP_READ_METHODS, Base::HTTP_WRITE_METHODS, Base::MAX_RETRIES
Instance Method Summary collapse
- #creds ⇒ Object
-
#get_access_token ⇒ Object
Looks like az account get-access-token caches the toke in ~/.azure/accessTokens.json and will update it only when it expires.
Methods inherited from Base
#append_api_version, #build_request, #headers, #http, #initialize, #request, #send_request, #set_headers!, #standarize_path, #url, #with_open_timeout
Methods included from Settings
#client_id, #client_secret, #endpoint, #group, #location, #resource, #subscription_id, #tenant_id
Methods included from HandleResponse
Methods included from Logging
#default_logger, #logger, #logger=
Constructor Details
This class inherits a constructor from Armrest::Api::Base
Instance Method Details
#creds ⇒ Object
20 21 22 23 |
# 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 ⇒ Object
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
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/armrest/api/auth/cli.rb', line 27 def get_access_token command = "az account get-access-token -o json" logger.debug "command: #{command}" out = `#{command}` if $?.success? JSON.load(out) else raise CliError, 'Error acquiring token from the Azure az CLI' end end |