Best answer by Mary Houston
View originalHow can I auth in python using a Collection ID and Collection token?
Hi all! Having trouble understanding how to auth in python using a Collection ID and Collection token. I don't see any example code in documentation. Anyone able to help?
Hi @eknudsen
- for using a Collection tokens, you will use the Collection ID instead of your Username. This should help!
```import requests
from requests.auth import HTTPBasicAuth
collection_id = 'add-collection-id-here'
url = 'https://api.getguru.com/api/v1/cards'
headers = {'accept': 'application/json'}
response = requests.get(url, headers=headers,
auth=HTTPBasicAuth("collection-id", "collection-token)")
response.json
return response```
![:wave: 👋](https://cdn.jsdelivr.net/emojione/assets/png/1f44b.png?v=2.2.7)
```import requests
from requests.auth import HTTPBasicAuth
collection_id = 'add-collection-id-here'
url = 'https://api.getguru.com/api/v1/cards'
headers = {'accept': 'application/json'}
response = requests.get(url, headers=headers,
auth=HTTPBasicAuth("collection-id", "collection-token)")
response.json
return response```
This worked perfectly @mhouston , thank you!
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.