I have always shied away from advertising. Nevertheless, users of my apps wanted to support me, so I got a bigger and bigger Patreon community.
However, to avoid having to enter each patron individually, I created a connection to the Patreon API with OAuth2.
I will try here to explain the first steps with this API and make it easier to get started.
1. Step One - Get your Client Registered
First register your Client on your Creator Account.
Make sure you selected Client API Version V1!
The redirect page doesn’t need to have any content, I recommend a note there that this authentication only works in the app.
2. Step Two - Get your One Time Code
To access a user token, the user must first agree to connect to your API. This is done through a Patreon website.
The URL must be customized with your client ID and redirect page and then displayed in WebViewer.
www.patreon.com/oauth2/authorize?response_type=code&client_id=<Your Client ID>&redirect_uri=<Your Redirect URL>
Once the page has been loaded and the user has logged in, the redirect page is displayed with the required information in the URL.
So we can make the webviewer invisible for now and take the “code” out of the URL.
3. Step Three - Get the Token
To get the token we need a web component to execute a POST with this data:
&grant_type=authorization_code&client_id=<Your Client ID>&client_secret=<Your Client Secret>&redirect_uri=<Your Redirect URL>
What we get now is the token and some other information like the time until it expires.
If this API is to be accessed in a proper way, the token must be refreshed. But I will not explain this now.
4. Step Four - Get your Data
We now have everything important behind us. Now we want to get the user data.
In this example we can check if the user supports our campaign and in which level.
In every request we make the token must be included in the header this is done as follows:
Now we get all the information from the user and the campaigns he supports in a JSON Format.
5. The finished Project:
Project AIA: Patreon_API.aia (7.8 KB)