# Problems with API to get list of patrons

**URL:** <https://www.patreondevelopers.com/t/problems-with-api-to-get-list-of-patrons/7134>\
**Category:** API Feedback\
**Created:** [March 4, 2023, 9:39pm UTC](https://www.patreondevelopers.com/t/problems-with-api-to-get-list-of-patrons/7134 "2023-03-04T21:39:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kersjan14](https://avatars.discourse-cdn.com/v4/letter/k/22d042/32.png) [@kersjan14](https://www.patreondevelopers.com/u/kersjan14)\
**Post date:** [March 4, 2023, 9:39pm UTC](https://www.patreondevelopers.com/t/problems-with-api-to-get-list-of-patrons/7134/1 "2023-03-04T21:39:04Z")

</div>

**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](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](https://www.patreon.com/api/oauth2/v2/campaigns/%7Bcampaign_id%7D/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?**

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [March 15, 2023, 9:19pm UTC](https://www.patreondevelopers.com/t/problems-with-api-to-get-list-of-patrons/7134/2 "2023-03-15T21:19:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Abu3safeer](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/abu3safeer/32/2604_2.png) [@Abu3safeer](https://www.patreondevelopers.com/u/Abu3safeer)\
**Post date:** [April 3, 2024, 10:56am UTC](https://www.patreondevelopers.com/t/problems-with-api-to-get-list-of-patrons/7134/3 "2024-04-03T10:56:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![codebard](https://yyz2.discourse-cdn.com/flex036/user_avatar/www.patreondevelopers.com/codebard/32/14_2.png) [@codebard](https://www.patreondevelopers.com/u/codebard)\
**Post date:** [April 8, 2024, 10:57pm UTC](https://www.patreondevelopers.com/t/problems-with-api-to-get-list-of-patrons/7134/4 "2024-04-08T22:57:08Z")

</div>

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.
