Class: Aspera::OAuth::JsonCredentials
- Defined in:
- lib/aspera/oauth/client/json_credentials.rb
Overview
Token creator using JSON credentials (e.g., username/password or apikey) sent to a login endpoint
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #create_token ⇒ Object
-
#initialize(json:, **generic_params) ⇒ JsonCredentials
constructor
A new instance of JsonCredentials.
Methods inherited from Base
absolute_url?, #authorization, #base_parameters, client_id_digest, #create_token_base, #endpoint_api, #endpoint_url, #renew_token, #renewed_authorization, #token
Constructor Details
#initialize(json:, **generic_params) ⇒ JsonCredentials
Returns a new instance of JsonCredentials.
15 16 17 18 19 20 21 22 |
# File 'lib/aspera/oauth/client/json_credentials.rb', line 15 def initialize( json:, **generic_params ) cache_id = json[:username] || Digest::SHA256.hexdigest(json[:apikey] || json.to_s)[0..23] super(**generic_params, cache_ids: [cache_id]) @body = json end |
Instance Method Details
#create_token ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/aspera/oauth/client/json_credentials.rb', line 24 def create_token token_api, subpath = endpoint_api(path_token) token_api.call( operation: 'POST', subpath: subpath, content_type: Mime::JSON, body: @body, headers: {'Accept' => Mime::JSON}, ret: :resp ) end |