Configuring 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 use category security settings to create private categories.

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.

24 Likes

So I have multiple patreon pages cuz i have a multiple community so is there anyway i can link up multiple patreon pages to discourse?

3 Likes

Nope. At least not yet. You can read more just above:

https://meta.discourse.org/t/configuring-patreon-integration-with-discourse/62380/107?u=jtbayly

2 Likes

Hi! After installing & setting everything up test seems to work fine, but after that on patreon the webhook is paused.

Any ideas?

1 Like

Hi!

I have it set up and users who are patrons can create an account and get put into the group Patrons. When they cancel their patreon membership, they are removed from the group Patrons. HOWEVER, they still have access to the discourse forum and are in the groups “trust_level_0” and “trust_level_1”.

Is there a way to:

  1. Remove their login credentials altogether when they stop subscribing?
  2. Automatically create the user account instead forcing the user to create the account after subscribing on Patreon?

Thanks!

1 Like

You could prevent these users from accessing your site’s content by configuring the security settings of all categories on your site so that only members of the Patron group can access the categories. Details about how to set that up are here: How to use category security settings to create private categories.

The Discourse Patreon plugin doesn’t handle this, but it looks like it would be possible to do it via Zapier with their Patreon integration. You could to use the “Delete Member Pledge” trigger to initiate sending an API request to Discourse to suspend the user.

Creating a user could be tricky, but you could set your forum to “Invite Only” and automate sending invites to the forum when a new member pledge is created on Patreon. This could also be done with Zapier. Details about setting that up are here: Automate sending Discourse invite emails with Zapier.

3 Likes

I configured Patreon in my Discourse forum and all works well, except that I can’t get the prompt to appear by:

  • Setting the checkbox “patreon donantion prompt enabled” to checked.
  • Entering a url from my forum in the “patreon donation prompt campaign url” setting.
  • Setting the “patreon donation prompt show after topics” to 20.

Where is the prompt supposed to appear?
Must I configure anything else?

Thanks in advance.

2 Likes

I reply myself. When you open 20 diferent topics, the prompt appears at the end of the last post in the topic :+1:

2 Likes

Is there an issue with the webhook implementation? We configured everything correctly. The normal sync works. And the Patreon tests of the webhook return status 200, though new pledges are not added/synced via the webhook, just over the 6 hours Sidekiq job.


Another question, if a user used a different email address for the Patreon account and the Discourse account, is it sufficient to add the email used at Patreon manually as an “alternate/secondary email” in the Discourse account? Will those be synced, too or is the Discourse user required to change his/her primary email for the sync to work?

2 Likes

I just tried this, and it worked. This is a much better solution than what I’ve been doing manually. Now I can push back on these troublesome users and tell them to add their own alternate email.

6 Likes

Perfect, thanks for letting me know. That is a lot easier than.

1 Like

@Falco

I have not had a chance to look at this super in-depth yet, but is it possible to have a different badge per Patreon tier?

2 Likes

It is possible to add users to a custom Discourse group based on their Patreon tier. See the Linking Patreon tiers to custom Discourse groups section of the guide for details about how to do that.

Once you are adding users to the custom group based on their Patreon tier, you could add a group flair to the group. You could also create a custom badge that is granted to members of the group.

3 Likes

This is the part I was interested in. I suppose with the proper setup, I could make it so that the user gets the badge for every month they are in the group which is dependant on whether you are still a patreon or not. Though making several different groups feels like a workaround. I’ll keep thinking on it.

If you are interested in our usecase:

We have 3 tiers, each one gets you a bronze or silver or gold shark (we model our badges after different colored sharks!). The gold tier also gets you the bronze and silver one for example. We’ve been manually doing these for years on our previous/current software, so automating all of the patreon badge granting once we are fully on Discourse will be awesome.

3 Likes

If I understand correctly, the plugin will already do everything you want. You might be missing the fact that the plugin truly “syncs” the groups every 6 hours. If they stop being a patreon, it will remove them from the groups. If they upgrade to gold-shark contribution level, it will move them to the gold-shark group.

Then award the badges with a badge query, or the group flair as @simon mentioned.

Making three groups doesn’t feel like a workaround to me.

2 Likes

Fair enough, I mean it does work really well. How about making it so that you get the badge every month you are in the group?

1 Like

So after a year you have 12 gold sharks? I don’t know how to do that, and you’re going to run out of room.

1 Like

Yeah.

That didn’t seem to be the case, in our testing just from the out of the box badges that come with discourse, if you get the same one multiple times, you get a little number in the corner marking how many times you have acquired said badge. I’ll have more time to poke at it over the weekend, but I appreciate all the feedback so far, it has given me things to think about.

2 Likes

Thanks for the plugin. Is it possible to combine manual assignment of users into a discourse usergroup with automatic assignment done by this plugin? Or will the plugin remove any member without a tier?

1 Like

Yes, it will remove them.

On a site I manage I created a mirror group for these users, same settings and privileges as the automatic group, same flair, but manually managed.

4 Likes