Skip to content

API: user_tokens

luqiuyuan edited this page Dec 10, 2020 · 2 revisions
VERB PATH DESC
POST /user_tokens log a user in
DELELE /user_token log a user out

POST /user_tokens

request

{
  "credential": {
    "email": "[email protected]",
    "password": "Ab123456"
  }
}

validations

  • credential (required)
    • email (required)
    • password (required)

response

see view SHOW

statuses and errors

STATUS ERROR TYPE DESC EXAMPLE
created (201) 创建成功
bad request (400) missing_field 缺少参数 { "code": "missing_field", "field": "credential:email" }
invalid_credential 用户名或密码错误 { "code": "invalid_credential" }

DELETE /user_token

response

see view SHOW

statuses and errors

STATUS ERROR TYPE DESC EXAMPLE
ok (200) 成功

Views

SHOW

{
  "user_token": {
    "user_id": 1,
    "key": "Due6daUTre",
    "expire_in": 2592000,
  }
}