How to create a "Login with Patreon" button

The approach you take is (in general) the same regardless of language. You’ll need to be able to deliver HTTP responses to visitors to your website, and make requests to the Patreon API, and pretty much every language can do that. You could implement this using a web service but that’s additional complexity that you don’t necessarily need, all of this functionality can be implemented in a single page.

  1. A user visits your website and clicks “Login with Patreon” which is a Login button URL containing your client ID and redirect URI – note: you can also automatically redirect, it doesn’t have to be a login button
  2. The user is asked by Patreon if they authorise your application to have access to their account information, if the user clicks accept:
  3. The user is redirected back to your website with a code parameter
  4. You take the code parameter value and send it to the Patreon API asking for an access token
  5. Patreon responds to your request with an access token which grants you access to the Patreon API on behalf of the user who logged in via Patreon
  6. Optional: You store the access token associated with the user in some way (session, local storage, database etc.)
  7. You make requests to the Patreon API with the access token to retrieve the user’s information

I have an example PHP project available on GitHub that implements this process which includes a step-by-step guide to implementing or you can download and use as-is, and you can find examples for a bunch of other languages in the various official Patreon libraries:

1 Like