DEV Community


Posted on

How to add Discord Authentication to FoundryVTT


1) Downloading the discord auth files

  1. Navigate to
  2. Click on the green code button: green code button
  3. Click Download as zip download as zip button

2) Extract the files to the foundry installation directory.

Either with a gui client such as 7zip or with terminal, extract the files to the path/to/foundry/resources/app directory. (where the main.js file is located)

Depending on what client you are using, it will ask to overwrite the main.hbs file. This is acceptable as the only modification to the original file is to load the discord script.

3) Create a new application on Discord

  1. Navigate to discord developers section
  2. Log into your discord account if needed.
  3. Either modify an existing application or create a new application.

4) Adding the Callback.

  1. Click the OAuth2 tab under your application OAuth2
  2. Click the Add Redirect button and add your foundrys url with /join at the end of it. redirect
  3. Click the save button.

5) Modify the discord.js script.

  1. While on your discord applications page, copy the application ID. app id
  2. Now open and edit the file public/scripts/discord.js

If you are using the application for windows, mac, Linux, etc it might be under path/to/foundry/resources/app/public/scripts/discord.js

  1. At the top of the file you will see the following configuration:


  1. Change the client ID to the one you have stored in your clipboard.
  2. Change the callback URL to match the one you saved in the redirects section on the discord developer portal.
  3. (Optional) You can choose to use id, email or just id if you want to simplify adding new users.

6) Setting up the discord authentication in your browser.

  1. Navigate to your Foundry url.
  2. Launch your world.
  3. Log in as Gamemaster or your GM account.
  4. Navigate to the user management screen
  5. You will now see several new fields, change the User Name to be your discord username. (If you click on your username in the discord application it will copy it to clipboard.)
  6. Set the discord ID to be your Discord ID. (You can get this by following this guide)
  7. Add the email for yourself.
  8. Set the access key.
  9. (Optional) Repeat steps 5 through 8 for each user.
  10. Click Save and Return

If you opted to only use Discord ID or Email, your form will look different.

form example

Log in with Discord

Logging in for the first time

  1. Click the Log in with Discord button
  2. Authorize the application.
  3. Enter your access key.


Returning to Foundry

  1. Enter your access key.

returning login

Top comments (0)