Method: Authentise::API::Users.create_session
- Defined in:
- lib/authentise/api/users.rb
.create_session(params) ⇒ Object
Create a new session to use in other API calls.
Params:
-
username
-
password
Returns a hash with:
-
token: cookie token to add to the following API cooke calls
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/authentise/api/users.rb', line 51 def create_session(params) url = "https://users.authentise.com/sessions/" = { content_type: :json, accept: :json, open_timeout: 2, timeout: 2, } body = params.to_json RestClient.post(url, body, ) do |response, _request, _result| if response.code == 201 { token: response.["session"], } else fail UnknownResponseCodeError.new(response.code, response) end end end |