Class: ResoWebApi::Authentication::TokenAuth
Overview
This implements a basic token authentication, in which a username/password (or API key / secret) combination is sent to a special token endpoint in exchange for a HTTP Bearer token with a limited lifetime.
Constant Summary
Constants inherited
from BaseClient
BaseClient::USER_AGENT
Instance Attribute Summary
Attributes inherited from AuthStrategy
#access
Instance Method Summary
collapse
#ensure_valid_access!, #reset
Methods inherited from BaseClient
#headers
Instance Method Details
#authenticate ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/reso_web_api/authentication/token_auth.rb', line 12
def authenticate
response = connection.post nil, auth_params
body = JSON.parse response.body
unless response.success?
message = "#{response.reason_phrase}: #{body['error'] || response.body}"
raise Errors::AccessDenied, response: response, message: message
end
Access.new(body)
end
|
#connection ⇒ Object
24
25
26
|
# File 'lib/reso_web_api/authentication/token_auth.rb', line 24
def connection
super.basic_auth(client_id, client_secret) && super
end
|