Skip to content

Authentication setup

khakers edited this page Mar 24, 2023 · 2 revisions

Setup procedure

  1. Navigate to the Discord Developer Portal
  2. Open the application you created for modmail (or an application of your choice)
  3. open the OAuth2 section
  4. You'll need to set the environment variable MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_ID to your client ID shown on the page, and MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_SECRET to the Client Secret next to it.
  5. Now, add the URL your modmail-viewer instance will be available at to the redirects with /callback appended. This url should be the same as what you set MODMAIL_VIEWER_URL to (except with /callback added, of course).

demonstration image, secret is not valid

Make sure to save your changes.

Now you'll need to generate a proper secret key for saving authentication, to be secure, it should be at least 32 characters. Make sure you keep this secure and don't share it, as anyone can use it to make authentication tokens. Once done, set it with the MODMAIL_VIEWER_SECRETKEY environment variable.

Finally, set MODMAIL_VIEWER_DISCORD_GUILD_ID to guild ID you plan on using for authentication. It's probably the same as what you've already set for modmail.

You should now have the following environment variables set:

  • MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_ID
  • MODMAIL_VIEWER_DISCORD_OAUTH_CLIENT_SECRET
  • MODMAIL_VIEWER_DISCORD_GUILD_ID
  • MODMAIL_VIEWER_SECRETKEY