Configure Patreon integration with Discourse

This guide assumes that you have a working Discourse installation with the Patreon Plugin already installed on it.

A few sections of the guide use your site’s domain. Enter that domain here so that it can be substituted into the instructions:

Obtaining your Patreon credentials

First, go to the Patreon Client & API Keys page and click the “Create Client” button to create a new client:

A form similar to this will open:

Fill in the App Name, Description, App Category, and Author fields. Then:

  • set the Company Domain field to =domain=

  • if you have an icon that you’d like to display on the Patreon Login form, enter your icon’s URL

  • set the Privacy Policy URL field to https://=domain=/privacy

  • set the Terms of Service URL to https://=domain=/tos

  • set the Redirect URIs field to https://=domain=/auth/patreon/callback

  • make sure the Client API version is set to 1

Once all the fields are complete, click the “Create Client” button.

If the form saves without errors, you will see an entry similar to this added to the page:

Click the caret icon to see the values that you’ll need to copy to Discourse.

Configuring Discourse

Go to your Discourse site’s Admin / Plugins page and click the “Settings” button for the “discourse-patreon” entry. The following settings will appear:

Copy the following credentials from Patreon:

  • copy your Patreon Client ID to the Discourse patreon client id setting
  • copy your Patreon Client Secret to the Discourse patreon client secret setting
  • copy your Patreon Creator’s Access Token to the Discourse patreon creator access token setting
  • copy your Patreon Creator’s Refresh Token to the Discourse patreon creator refresh token setting

For now, leave the patreon webhook secret setting blank.

If you would like a prompt to appear on your site to encourage non-patreons to become supporters, select the patreon donation prompt enabled checkbox and enter your Patreon campaign’s URL into the patreon donation prompt campaign url setting.

If you would like to allow users to login to Discourse via Patreon, first enter the Discourse username that shares the same email address as your Patreon account’s email address into the patreon creator discourse username setting. Then, select the patreon login enabled checkbox.

Finally, make sure you have checked the patreon enabled checkbox to enable the Patreon plugin.

Running the First Sync

Now that everything is set up, go to https://=domain=/admin/plugins/patreon:

image

Click the “Update Patreon Data” button to pull data about your Patreon reward tiers to Discourse. Clicking the button starts a process that takes a while (usually 30 seconds or so) to complete. If everything is configured correctly, you should see a message like this:

image

After refreshing the page, details about your Patreon reward tiers will be available in the “Rewards” dropdown.

Linking Patreon tiers to custom Discourse groups

Use the form’s Group and Rewards fields to configure which Discourse groups should be associated with your Patreon account’s reward tiers. The form’s Group dropdown will contain all custom groups that you have created on the site, plus the Patron group that is created by the Discourse Patreon plugin. The Rewards dropdown contains all of your Patreon reward tiers. To create a new entry, select a group and a reward tier, then click the Save icon to save the record:

Once you have associated one or more Discourse groups with your reward tiers, click the “Update Patreon Data” button again to sync any of your existing users who are also your supporters on Patreon. Syncing the users will add them to the appropriate Discourse groups.

Assuming that you associated the Patron group with your “$0 - All Patrons” tier, you should now see that any existing users on your site who have signed up for that reward tier have been added to your Patrons group.

Patron group default settings

By default, when a user is added to the Patron group, a Patreon flair will be added to their avatar and they will be granted the Patron badge.

You can change or remove the avatar flair by going to the Patron group’s page and clicking the “Manage” tab:

From that tab you can also customize the About Group text that is displayed on your groups page.

The Patron badge can be customized or disabled from the Patron entry that the plugin adds to your site’s Admin / Badges page.

Configuring the optional Patreon Webhook

The Discourse Patreon plugin runs a background job 4 times a day to sync users on your site to groups that you have linked with Patreon. If you would like the syncing to happen faster than that, you can configure a webhook to trigger a new sync every time someone signs up for a reward tier on your Patreon account.

To do that, first visit Patreon and create a new webhook that is pointing to https://=domain=/patreon/webhook

The result will be similar to this. :warning: Make sure to not expose the SECRET that is created:

Turn on the Create Pledge, Update Pledge, and Delete Pledge triggers:

Now copy the webhook secret to your Discourse patreon webhook secret site setting. Once that has been saved on Discourse, Discourse groups will be synced to Patreon each time a pledge is updated.

Limiting access to your site to Patreon supporters

If you enable Patreon login to your Discourse site, you can limit access to the site to only allow users with Patreon accounts to create an account or login. To do this, first make sure that logging into your site via Patreon is working for you, then disable your Discourse site’s enable local logins and enable local logins via email settings. With those settings disabled, the only way users will be able to access your site is through the Login with Patreon link.

Only allowing users with Patreon account to login to your site does not limit access to the site to your Patreon supporters. Users with Patreon accounts who are not your supporters will still be able to use the login link. To only allow your supporters to be able to access your site’s content, you need to configure your site’s category security settings to limit access to some or all of your site’s categories to members of Discourse groups that you have linked to Patreon. Details about how to set that up can be found here: How to create private categories using category permission / security settings.

Debugging issues with verbose logging

You can enable the site setting patreon verbose log in the site settings at any moment to help you debug issues in either the login or the patron sync feature. After enabling it, logs will be available https://=domain=/logs.


Last Reviewed by @AlexDev on 2022-05-24T20:00:00Z

25 Likes