Module: FmRest::V1::Auth
- Included in:
- FmRest::V1
- Defined in:
- lib/fmrest/v1/auth.rb
Constant Summary collapse
- ACCESS_TOKEN_HEADER =
"X-FM-Data-Access-Token"
Instance Method Summary collapse
-
#request_auth_token(connection = FmRest::V1.auth_connection) ⇒ Object
Requests a token through basic auth.
-
#request_auth_token!(connection = FmRest.V1.auth_connection) ⇒ Object
Requests a token through basic auth, raising
FmRest::APIError::AccountError
if auth fails.
Instance Method Details
#request_auth_token(connection = FmRest::V1.auth_connection) ⇒ Object
Requests a token through basic auth
14 15 16 17 18 |
# File 'lib/fmrest/v1/auth.rb', line 14 def request_auth_token(connection = FmRest::V1.auth_connection) request_auth_token!(connection) rescue FmRest::APIError::AccountError false end |
#request_auth_token!(connection = FmRest.V1.auth_connection) ⇒ Object
Requests a token through basic auth, raising
FmRest::APIError::AccountError
if auth fails
26 27 28 29 |
# File 'lib/fmrest/v1/auth.rb', line 26 def request_auth_token!(connection = FmRest.V1.auth_connection) resp = connection.post(V1.session_path) resp.headers[ACCESS_TOKEN_HEADER] || resp.body["response"]["token"] end |