Skip to content

Authorization

Vadim Sokoltsov edited this page Nov 13, 2016 · 3 revisions

POST /api/v1/sessions

Sign in user and create new authorizaiton object (or update previous)

Request parameters

  • email - type: string - user's email - requered
  • password - type: string - user's password - requered
  • authorization - type: json - object with information about user's client - required

authorization object should include fields:

  • platform - information about client's OS
  • platform_version - version of client's OS
  • app_name - name of the client (browser version, mobile app name, etc.)
  • app_version - version of the client (browser version, mobile app name, etc.)
  • provider - default: UProgress - name of the application through which authorization has been completed

Errors

  • email - can't be blank, is invalid
  • password - can't be blank, is too short (minimum is 6 characters)
  • authorization - can't be blank

Response parameters

  • token - encrypted authorization token

Request example

{
  "user": {
    "email": "ololosh@mail.ru",
    "password": "Password123",
    "authorization": {
      "platform": "macOS",
      "platform_version": "10.11",
      "app": "Google Chrome",
      "app_version": "56.14.3",
      "provider": "UProgress"
    }
  }
}

Success response example

{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTA0OX0.B0X5T35HnHJ_2AxoKp6CeiTTq2n_lcoHc5X7hNGdFo0"
}

Failed response example

{
  "errors": {
    "email": [
      "can't be blank",
      "is invalid"
    ]
  }
}

GET /api/v1/sessions/current

Receive current user information

Request parameters

None

Errors - status 401

Available messages:

  • User not found
  • Authorization token invalid
  • Authorization token expired

Success response example

{
  "current_user": {
    "id": <user id>,
    "email": <user email>,
    "nick": <user nick>,
    "first_name": null,
    "last_name": null,
    "description": null,
    "location": null,
    "attachment": null
  }
}

Failed response example

{
  "user": null
}

Clone this wiki locally