Class: Roqua::CoreApi::Sessions::HmacAuthRequest
- Inherits:
-
AuthSession
- Object
- AuthSession
- Roqua::CoreApi::Sessions::HmacAuthRequest
- Defined in:
- lib/roqua/core_api/sessions/hmac_auth_request.rb
Overview
Make a single hmac signed request. HmacAuthRequest.new(consumer_key: ‘mykey’, consumer_secret: ‘…’) HmacAuthRequest.new(consumer_key: ‘mykey’, hmac: ‘…’, nonce: ‘…’, timestamp: 1467704698)
Instance Attribute Summary collapse
-
#consumer_key ⇒ Object
readonly
Returns the value of attribute consumer_key.
-
#consumer_secret ⇒ Object
readonly
Returns the value of attribute consumer_secret.
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Attributes inherited from AuthSession
Instance Method Summary collapse
-
#access_denied(response) ⇒ Object
handle 401 response.
- #headers(request_method, path, params) ⇒ Object
-
#initialize(consumer_key: ENV.fetch('CORE_CONSUMER_KEY'), consumer_secret: ENV.fetch('CORE_CONSUMER_SECRET'), timestamp: Time.now.to_i, nonce: SecureRandom.urlsafe_base64(32), hmac: nil, **additional_arguments) ⇒ HmacAuthRequest
constructor
A new instance of HmacAuthRequest.
Methods inherited from AuthSession
Constructor Details
#initialize(consumer_key: ENV.fetch('CORE_CONSUMER_KEY'), consumer_secret: ENV.fetch('CORE_CONSUMER_SECRET'), timestamp: Time.now.to_i, nonce: SecureRandom.urlsafe_base64(32), hmac: nil, **additional_arguments) ⇒ HmacAuthRequest
Returns a new instance of HmacAuthRequest.
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 10 def initialize(consumer_key: ENV.fetch('CORE_CONSUMER_KEY'), consumer_secret: ENV.fetch('CORE_CONSUMER_SECRET'), timestamp: Time.now.to_i, nonce: SecureRandom.urlsafe_base64(32), hmac: nil, **additional_arguments) @consumer_key = consumer_key @consumer_secret = consumer_secret @timestamp = @nonce = nonce @hmac = hmac super(**additional_arguments) end |
Instance Attribute Details
#consumer_key ⇒ Object (readonly)
Returns the value of attribute consumer_key.
8 9 10 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 8 def consumer_key @consumer_key end |
#consumer_secret ⇒ Object (readonly)
Returns the value of attribute consumer_secret.
8 9 10 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 8 def consumer_secret @consumer_secret end |
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
8 9 10 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 8 def nonce @nonce end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
8 9 10 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 8 def @timestamp end |
Instance Method Details
#access_denied(response) ⇒ Object
handle 401 response.
29 30 31 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 29 def access_denied(response) fail Unauthorized, response end |
#headers(request_method, path, params) ⇒ Object
24 25 26 |
# File 'lib/roqua/core_api/sessions/hmac_auth_request.rb', line 24 def headers(request_method, path, params) {'Authorization' => "HMAC #{consumer_key}:#{hmac(request_method, path, params)}:#{nonce}:#{}"} end |