Get Started

Setup

To create a new project that can be used to authenticate users, follow these simple steps:

  1. Log into the JustAuthenticate dashboard.
  2. Create a new project.
  3. Copy & save the project id.
  4. Set the name, description and redirect url for the project.
  5. Change any other settings for the project (this can also be done at a later time).
  6. Press the save changes button, to make sure the project is good to go.
  7. Press the reset secret button to get the project's secret, which will be used later.

Once this is done you need to make sure you have both the project id (see step 3 above) and the project secret (see step 7 above) saved, these will be used to authenticate users correctly.

Usage

Using JustAuthenticate to authenticate a user consists of 2 steps:

  • First is sending the user to the login page with the right id.
  • And then fetching the user data from our API.

Send user to login screen

When a user needs to login to your site, they will need to be sent to our login page with the correct project id.

The link to send the user to is https://justauthenticate.stevnbak.dk/login/<project_id>

The project id can be found on the project's dashboard (see setup).

Fetch user data from api

Once the user has succesfully logged in through their preferred platform, they will be redirected to the project's redirect URL (see settings), with a single-use and time-limited login code.

For example a user could be redirected to https://justauthenticate.stevnbak.dk/api/login/<login_code> or https://justauthenticate.stevnbak.dk/api/login?code=<login_code> (based on the project settings).

The login code can be used to fetch the user data by sending a POST request to https://justauthenticate.stevnbak.dk/api/auth/user, with a body that contains both the project secret and login code like this:

{
    "code": "<login_code>",
    "secret": "<project_secret>"
}

The api response will be in JSON format and will look like this (see API for details):

{
    "user": {
        "_id": "659835a51ea5db0d5f2124f7",
        "username": "stevnbak",
        "email": "user@example.com",
        "avatar": "https://cdn.discordapp.com/avatars/avatar.png",
        "verified": true,
        "platform": "discord"
    }
}