Auth

Register

Allows a user to register for a account.

Path

POST /auth/register

Headers

FieldTypeDescription
Content-Typestringapplication/x-www-form-urlencoded

Body

FieldTypeDescription
usernamestringUsername of the new account.
emailstringEmail of the new account.
passwordstringPassword of the new account.

Example

curl --location --request POST 'https://www.example.com/api/auth/register' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'username=usermrdemonwolfgithubio' \
--data-urlencode 'email=user@mrdemonwolf.github.io' \
--data-urlencode 'password=user@mrdemonwolf.github.io'
{
  "code": "PENDING_CONFIRMATION",
  "error": "Please confirm your email address to complete the registration."
}

Login

Allows a user to login with their account.

Path

POST /auth/login

Headers

FieldTypeDescription
Content-Typestringapplication/x-www-form-urlencoded

Body

FieldTypeDescription
emailstringEmail of the current account.
passwordstringPassword of the current account.

Example

curl --location --request POST 'https://www.example.com/api/auth/login' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'email=user@mrdemonwolf.github.io' \
--data-urlencode 'password=uuser@mrdemonwolf.github.io'
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE1OTMsImV4cCI6MTU5OTI0MzM5M30.FuLUNEc_lE8jI2KEur0KsQzZFjIh5kymnLdR0Udycxk",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE1OTMsImV4cCI6MTU5OTMyNzk5M30.QtOrs1kJyh7sWDt2Y0_VpPRyXYZcfK9W4SR-YsxCrHk",
  "twoFactor": false
}

Login with Two Factor

Allows a user to login with their account if two factor is enabled.

Path

POST /auth/two-factor

Headers

FieldTypeDescription
Content-Typestringapplication/x-www-form-urlencoded

Body

FieldTypeDescription
TokenstringLogin initialize two factor token.
CodestringCode from the Two Factor from app.

Example

curl --location --request POST 'https://www.example.com/api/auth/two-factor' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'token=qh8C0G8azJRUJmdn9jCiZNJ0pTLmBldoChcRvPgt31GEOD5sShmHzqn7ROCzqwU2' \
--data-urlencode 'code=110450'
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE1OTMsImV4cCI6MTU5OTI0MzM5M30.FuLUNEc_lE8jI2KEur0KsQzZFjIh5kymnLdR0Udycxk",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE1OTMsImV4cCI6MTU5OTMyNzk5M30.QtOrs1kJyh7sWDt2Y0_VpPRyXYZcfK9W4SR-YsxCrHk",
  "twoFactor": true
}

Login Refresh

Allows a user to refresh their login token with a new one

Path

POST /auth/refresh

Headers

FieldTypeDescription
Content-Typestringapplication/x-www-form-urlencoded

Body

FieldTypeDescription
refresh_tokenstringJWT refresh token.

Example

curl --location --request POST 'https://www.example.com/api/auth/refresh' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'refresh_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE1OTMsImV4cCI6MTU5OTMyNzk5M30.QtOrs1kJyh7sWDt2Y0_VpPRyXYZcfK9W4SR-YsxCrHk' \
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE3MjIsImV4cCI6MTU5OTI0MzUyMn0.OUiiTCNHlwRkbLjjtRtkD2I90-vcTKGvjlOlTcdg_Og",
  "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjRiZmYxMjEwMzdlNDI0YTE3YTNlYmMiLCJpYXQiOjE1OTkyNDE3MjIsImV4cCI6MTU5OTMyODEyMn0.vWp-l7WGCPWS1zTUeldd_8arjG5KC4YDVhFU0b-E6As"
}

Logout

Allows a user logout of their account which revokes the current login token.

Path

POST /auth/logout

Headers

FieldTypeDescription
AuthorizationstringJWT token.
Content-Typestringapplication/x-www-form-urlencoded

Example

curl --location --request POST 'https://www.example.com/api/auth/logout' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1ZjEwYjBkMjEwZDZhNzBiZTE0OTdkZTEiLCJpc3MiOiJodHRwczovL2ZlZmE0M2RkZDVjYi5uZ3Jvay5pbyIsImlhdCI6MTU5NDkyOTQzNSwiZXhwIjoxNTk0OTMxMjM1fQ.U5pH17a88I0LSSLzlA4N4pnelgbB3P8358rc_3CKh64'
{
  "code": "LOGGED_OUT",
  "error": "You are now logged out."
}