Authentication API

v1/login: Login with username and password

Asserts that the username and password combination are valid, then returns a token that can be used to authenticate future requests. The token does not expire, but can be invalidated with v1/logout.

Input:

{ "username": "", "password": "" }

Output:

{ "success": true, "token": "", "uid": "" }

v1/signup: Sign up with details

Signs up a user with the given details. Further customisation should be done through the v1/updateUser endpoint. The user will be automatically logged in, so a token will be returned, along with the new user's ID. If the user name already exists, an error will occur.

Input:

{ "username": "", "password": "", "displayName": "", "email": "" }

Output:

{ "success": true, "token": "", "uid": "" }

v1/logout: Logout and invalidate token

Logs out the user and invalidates the token.

Input:

{ "token": "" }

Output:

{ "success": true }

v1/validateToken: Validate token

Asserts that the token is valid, and if so, returns the user's ID. Used for restoring sessions.

Input:

{ "token": "" }

Output:

{
  "success": true,
  "uid": ""
}