Problems with API to get list of patrons

Hi, Im trying to use the API to get the latest list of patrons, however I can’t get the API to work properly,

the code I used:

import requests

# Replace these values with your own
client_id = ‘YOUR_CLIENT_ID’
client_secret = ‘YOUR_CLIENT_SECRET’
access_token = ‘YOUR_ACCESS_TOKEN’
campaign_id = ‘YOUR_CAMPAIGN_ID’

# Authenticate with the Patreon API
auth_url = ‘https://www.patreon.com/api/oauth2/token
auth_data = {

  • ‘grant_type’: ‘client_credentials’,*
  • ‘client_id’: client_id,*
  • ‘client_secret’: client_secret,*
    }
    auth_response = requests.post(auth_url, data=auth_data)
    access_token = auth_response.json()[‘access_token’]

# Get the list of patrons
patrons_url = f’https://www.patreon.com/api/oauth2/v2/campaigns/{campaign_id}/members
patrons_headers = {

  • ‘Authorization’: f’Bearer {access_token}',*
    }
    patrons_response = requests.get(patrons_url, headers=patrons_headers)
    patrons = patrons_response.json()[‘data’]

# Extract the names of the patrons
patron_names = [patron[‘attributes’][‘full_name’] for patron in patrons]

# Print the list of names
print(patron_names)

But the only response I get from the API is this:

Traceback (most recent call last):
File “D:\GitHub\CocktailCodex\check.py”, line 17, in
access_token = auth_response.json()[‘access_token’]
KeyError: ‘access_token’

And when I just print “auth_response.json()” it says this:

[{‘code’: None, ‘code_name’: ‘InternalError’, ‘detail’: ‘An unrecoverable internal server error has occurred.’, ‘id’: ‘XXXXX’, ‘status’: ‘500’, ‘title’: ‘Internal Error.’}]

What is it / can it be, and how can i solve my problems?

Try double-checking that you are receiving a valid v2 access token and using it with a v2 endpoint and v2 calls.

I am having the same issue here, is it even possible with v2?

Make sure you are using v2 endpoints. If you are, make sure that you are using a token with correct scopes. (all the fields and resources that you are requesting must be authorized) If you are accessing your own campaign, use your creator’s access token.