$ docker-compose up --build
# access to localhost:3000
devise-token-auth を利用しています
POST /v1/users/auth/
Request
{
"email":"[email protected]",
"password":"password",
"password_confirmation": "password"
}
Response
{
"status":"success",
"data":{
"uid":"[email protected]",
"id":1,
"email":"[email protected]",
"provider":"email",
"allow_password_change":false,
"name":null,
"nickname":null,
"image":null,
"created_at":"2020-04-16T02:58:40.765Z",
"updated_at":"2020-04-16T02:58:40.889Z"
}
}
POST /v1/users/auth/sign_in
Request
{
"email":"[email protected]",
"password":"password"
}
ResponseHeader
"access-token": "G1Fcytw8FkhlYhMWRypBjA"
"token-type": "Bearer"
"client": "CIX_z6sBzKghvoh4ZhiV5A"
"expiry": "1588234471"
"uid": "[email protected]"
ResponseBody
{
"data": {
"id": 1,
"email": "[email protected]",
"provider": "email",
"uid": "[email protected]",
"allow_password_change": false,
"name": null,
"nickname": null,
"image": null
}
}
レスポンスヘッダにあるaccess-token, token-type, client, uidを各エンドポイントのリクエストヘッダに追加することで認証できる。
適当なエンドポイントを叩く
GET /v1/todos
RequestHeader
"access-token": "G1Fcytw8FkhlYhMWRypBjA"
"client": "CIX_z6sBzKghvoh4ZhiV5A"
"uid": "[email protected]"
ResponseBody
[]