Class: Aspera::FaspexPubLink
- Inherits:
-
OAuth::Base
- Object
- OAuth::Base
- Aspera::FaspexPubLink
- Defined in:
- lib/aspera/api/faspex.rb
Overview
Implement OAuth for Faspex public link
Class Attribute Summary collapse
-
.additional_info ⇒ Object
Returns the value of attribute additional_info.
Attributes inherited from OAuth::Base
#api, #client_id, #path_token, #scope
Instance Method Summary collapse
- #create_token ⇒ Object
-
#initialize(context:, redirect_uri:, path_authorize: 'authorize_public_link', **base_params) ⇒ FaspexPubLink
constructor
A new instance of FaspexPubLink.
Methods inherited from OAuth::Base
#authorization, #create_token_call, #optional_scope_client_id, #token
Constructor Details
#initialize(context:, redirect_uri:, path_authorize: 'authorize_public_link', **base_params) ⇒ FaspexPubLink
Returns a new instance of FaspexPubLink.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/aspera/api/faspex.rb', line 16 def initialize( context:, redirect_uri:, path_authorize: 'authorize_public_link', **base_params ) # a unique identifier could also be the passcode inside super(**base_params, cache_ids: [Digest::SHA256.hexdigest(context)[0..23]]) @context = context @redirect_uri = redirect_uri @path_authorize = end |
Class Attribute Details
.additional_info ⇒ Object
Returns the value of attribute additional_info.
11 12 13 |
# File 'lib/aspera/api/faspex.rb', line 11 def additional_info @additional_info end |
Instance Method Details
#create_token ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/aspera/api/faspex.rb', line 29 def create_token # Exchange context (passcode) for code resp = api.call( operation: 'GET', subpath: @path_authorize, query: { response_type: :code, state: @context, client_id: client_id, redirect_uri: @redirect_uri }, exception: false ) # code / state located in redirected URL query info = Rest.query_to_h(URI.parse(resp[:http]['Location']).query) Log.dump(:info, info) raise Error, info['action_message'] if info['action_message'] Aspera.assert(info['code']){'Missing code in answer'} # Exchange code for token return create_token_call(optional_scope_client_id.merge( grant_type: 'authorization_code', code: info['code'], redirect_uri: @redirect_uri )) end |