-
Notifications
You must be signed in to change notification settings - Fork 19
User Authentication
Isaac Hunter edited this page Sep 13, 2024
·
2 revisions
The server uses JSON Web Token (JWT) for user authentication.
You can use any email and password, this example uses the email user@example.com and password changeme for demonstration purposes.
-
Register a user via
/api/user/register, the body must look like this:{ "email": "user@example.com", "password": "changeme" }This will return the new user's email and id.
-
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": "user@example.com", "password": "changeme" }This will return the token like this:
{ "token": "token-value-here" } -
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
Bearerin front, and separated by a space) - If using postman, go to the "Headers" tab and use
Authorizationas the key andBearer token-value-hereas the value - If you are
raw dogging itmanually 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.)
- 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