API – Authorization
Collaborator uses the Json Web Token authorization algorithm
- To authorize, you need to send POST request for this URI /api/rest.php/auth/session
- The body of the request must contain a JSON object with the following obligatory fields email and password, The Collaborator can use both login and email as a login.
- The request must contain the following heading Content-Type: application/json;charset=UTF-8.
Request example:
curl 'http://your-domain.davintoo.com/api/rest.php/auth/session' -H 'Content-Type: application/json;charset=UTF-8' --data-binary '{"email":"api","password":"admin"}'
Answer
-
In case of successful authorization (HTTP answer code - 200) Collaborator returns a JSON object with information about the current user and JWT Token into the field _accesstoken:
{"id":"1","login":"api","firstname":"API","secondname":"Import","international_name":null,"patronymic":"","facebook_id":null,"google_id":null,"email":"[email protected]","gender":"male","birth_date":"01.01.1970","tags":null,"is_active":true,"jwt_token":"xxxxxxxxx","site_id":"1"}
-
In case of error (HTTP answer code - 400) returns JSON object with error information:
{"error":"User with this email does not exists"}