The documentation on Patreon OAuth and API is the worst I’ve yet seen. It took me a few days just to successfully send a request and 2 more days trying to achieve a simple goal: get user’s current tier in my patreon.
In short, I’m working on a website where a logged in user can connect his Patreon account, so I know which tier he’s got. Sounds simple, but the lack of information and unsupported github repos drive me crazy already. It’s been too long.
I’m running a Heroku server (because from localhost I cannot access the API at all) and using Express JS as my server.
Whenever user has been redirected from the Patreon auth to get the “code”, it’s pretty easy to follow the github JS repo and get user info, HOWEVER in object “pledges” there is an ID. What is this ID? I’ve specifically went to my Patreon panel and checked network requests for my tiers, and none of the IDs I got are similar with the ones from API request.
I’m using this code snippet to receive user info.
I’ve tried v1 first, had this problem, and then tried V2 which does not work no matter what I try, I always get 401, 403, 405, but the only time it does work and I get access token, I always get “method does not exist” or something, even following other people’s guides and threads. Now I’m back to V1 because it at least works.
What is the EXACT code required to get user’s CURRENT tier in my Patreon?
I’ve never ever on the entire internet have seen ANY code example, and specifically the one that actually works. Any help would be highly appreciated.
Tell me about it. The API is on life support and it’s a critical part of our membership automations. I wish Patreon would notice how important this is for so many people if they can get it right. I spent about a week messing around with the API because the docs are missing some pieces but here’s a fully working example that pulls all the information I needed. I get the member ID from the New Member Webhook.
I never knew there is a requirement to supply a user-agent. I wonder why it’s even needed, because my requests happen on the server and there is no browser… using a hardcoded one.
Unfortunately, I get 401: unauthorized.
Wonder if it’s because I’m using JS Library they provide to get the token (which is V1 only) and you show an example from V2.
Also, had to rewrite your code, have a look
You should work with api v2 using the examples provided in the documentation for JS library is not currently maintained. Checking the PHP library for example code can help you adopt the logic from there to your JS code.
User agent is expected to reduce the spam/hack bots which tend to omit that header.