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
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, #base_params, #create_token_call, #token
Constructor Details
#initialize(context:, redirect_uri:, path_authorize: 'authorize_public_link', **base_params) ⇒ 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 = 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 54 |
# File 'lib/aspera/api/faspex.rb', line 29 def create_token # Exchange context (passcode) for code http = api.call( operation: 'GET', subpath: , query: { response_type: :code, state: @context, client_id: params[:client_id], redirect_uri: @redirect_uri }, exception: false, ret: :resp ) # code / state located in redirected URL query info = Rest.query_to_h(URI.parse(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(base_params.merge( grant_type: 'authorization_code', code: info['code'], redirect_uri: @redirect_uri )) end |