Skip to content

User Authentication

Isaac Hunter edited this page Sep 13, 2024 · 2 revisions

User Authentication

The server uses JSON Web Token (JWT) for user authentication.

Authenticating via REST API

You can use any email and password, this example uses the email [email protected] and password changeme for demonstration purposes.

  1. Register a user via /api/user/register, the body must look like this:

    {
      "email": "[email protected]",
      "password": "changeme"
    }

    This will return the new user's email and id.

  2. Request a new token via /api/user/token. This is akin to logging the user in, and must be passed the user's email and password like this:

    {
      "email": "[email protected]",
      "password": "changeme"
    }

    This will return the token like this:

    {
      "token": "token-value-here"
    }
  3. This token value will need to be inserted into the header of each authenticated request in the format:

    Authorization: Bearer token-value-here
    • If you are setting this up on the docs page, click the button that says "Authorize" and past the token value in there (with the word Bearer in front, and separated by a space)
    • If using postman, go to the "Headers" tab and use Authorization as the key and Bearer token-value-here as the value
    • If you are raw dogging it manually testing the endpoints in the browser (specifically Chrome), I recommend using this Chrome extension for manually injecting headers into your requests: ModHeader. (If you are constantly refreshing the docs page, this extension will allow you to store headers between page refreshes.)
Clone this wiki locally