Create

Now that you activated your account, you can log in.

curl -X 'POST' \
  'http://localhost:8000/api/v1/towns/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "My Town Name"
}' \
  --header 'Authorization: Bearer <api_token>'

In the response you will receive an auth_token. The authentication method that is used in Restfall is known as Authentication Bearer.

Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the Authorization header when making requests to protected resources:

In order to validate whether your auth token is working, you might want to use users/me endpoint. It’s a common convention that returns _some_ information about your account. In this case, it should return your id - the id of your user.

curl -X 'GET' 'http://localhost:8000/api/v1/users/me/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  --header 'Authorization: Bearer <auth_token>'