Skip to content
This repository was archived by the owner on May 7, 2021. It is now read-only.

API: Authentication

Stephen Li edited this page Oct 31, 2015 · 2 revisions

This page details how to authenticate with the API server. Presently, every endpoint except /auth/signup and /auth/logout requires authentication. Any unauthenticated requests to any other endpoints will return a 401 error.

The API server uses token-based authentication. Any authenticated requests must be made with the Authorization header with the format Token {actual_token}. For example:

POST /auth/logout HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Token 675b51c53c94a5af46948097659984cd5a272507
Connection: keep-alive
Content-Length: 0
Host: localhost:8000
User-Agent: HTTPie/0.9.2

HTTP/1.0 200 OK
Allow: POST, OPTIONS
Content-Type: application/json
Date: Sat, 31 Oct 2015 18:45:35 GMT
Server: WSGIServer/0.1 Python/2.7.6
Vary: Accept
X-Frame-Options: SAMEORIGIN

{
    "success": true
}

Sign up

Endpoint

POST /auth/signup

Description

Log in

Endpoint

POST /auth/login

Description

Log out

Endpoint

POST /auth/logout

Description

Invalidates the user's current token on the server. Returns 200 if provided token is authenticated and a JSON body that describes whether or not the operation was successful.

POST /auth/logout HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Authorization: Token 675b51c53c94a5af46948097659984cd5a272507
Connection: keep-alive
Content-Length: 0
Host: localhost:8000
User-Agent: HTTPie/0.9.2

HTTP/1.0 200 OK
Allow: POST, OPTIONS
Content-Type: application/json
Date: Sat, 31 Oct 2015 18:45:35 GMT
Server: WSGIServer/0.1 Python/2.7.6
Vary: Accept
X-Frame-Options: SAMEORIGIN

{
    "success": true
}

Clone this wiki locally