How to get user's tier using API V1

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.

patreonOAuthClient = patreonOAuth(CLIENT_ID, CLIENT_SECRET)
        .getTokens(oauthGrantCode, redirectURL)
        .then(function (tokensResponse) {
            const apiClient = patreonAPI(tokensResponse.access_token)
            return apiClient('/current_user/campaigns')
        }).then((result) => {
            var store =

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.

var url = '' + inputData.patreonID + '?include=address&fields%5Baddress%5D=addressee,line_1,line_2,city,state,postal_code,country,phone_number&fields%5Bmember%5D=full_name,is_follower,email,last_charge_date,last_charge_status,lifetime_support_cents,patron_status,currently_entitled_amount_cents,pledge_relationship_start,will_pay_amount_cents'

const getMemberInfo = await fetch(url, {
  headers: {
      'Authorization': 'Bearer YOUR-ACCESS-TOKEN',
      'user-agent': 'Chrome: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36'
const res = await getMemberInfo.json();

  return {res}

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

const patreonOAuthClient = patreonOAuth(CLIENT_ID, CLIENT_SECRET)
        .getTokens(oauthGrantCode, redirectURL)
        .then(tokensResponse => {
            token = tokensResponse.access_token
            const apiClient = patreonAPI(token)
            return apiClient('/current_user')
        }).then((result) => {
            var store =
            return JSON.stringify(store.rawJson)
        }).then((thing) => {
            var url = '' + USER_ID + '?include=address&fields%5Baddress%5D=addressee,line_1,line_2,city,state,postal_code,country,phone_number&fields%5Bmember%5D=full_name,is_follower,email,last_charge_date,last_charge_status,lifetime_support_cents,patron_status,currently_entitled_amount_cents,pledge_relationship_start,will_pay_amount_cents'

            fetch(url, {
                headers: {
                    'Authorization': 'Bearer ' + token,
                    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36'
            }).then((restt) => {
                return restt.json()
            }).then(final => {
                console.log('FINAL:', final)
            }).catch(err1 => {
        }).catch(err => {
            console.log('ERROR FINAL:', err)

I’ll go scrap some more forums and see why it could be unauthorized. Thanks for the help so far, but assistance still needed

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.