Module: WrAPI::Authentication
- Included in:
- API
- Defined in:
- lib/wrapi/authentication.rb
Overview
Deals with authentication flow and stores it within global configuration following attributes should be available:
username
password
access_token
token_type
refresh_token
token_expires
Instance Method Summary collapse
-
#api_auth(path, options = {}) ⇒ String
Authenticates the API request by merging the provided options with the API access token parameters, sending a POST request to the specified path, and processing the response to extract the access token.
-
#api_refresh(path, token) ⇒ String
Refreshes the API token by making a POST request to the specified path with the given refresh token.
Instance Method Details
#api_auth(path, options = {}) ⇒ String
Authenticates the API request by merging the provided options with the API access token parameters, sending a POST request to the specified path, and processing the response to extract the access token.
19 20 21 22 23 24 |
# File 'lib/wrapi/authentication.rb', line 19 def api_auth(path, = {}) params = api_access_token_params.merge() response = post(path, params) # return access_token api_process_token(response.body) end |
#api_refresh(path, token) ⇒ String
Refreshes the API token by making a POST request to the specified path with the given refresh token.
31 32 33 34 35 36 37 |
# File 'lib/wrapi/authentication.rb', line 31 def api_refresh(path, token) params = { refreshToken: token } response = post(path, params) # return access_token api_process_token(response.body) end |