Skip to main content
Solved

How can I auth in python using a Collection ID and Collection token?

  • March 22, 2021
  • 2 replies
  • 105 views

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?

Best answer by Mary Houston

Hi @eknudsen :wave: - 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```

2 replies

Mary Houston
Forum|alt.badge.img
  • Smart Cookie
  • Answer
  • March 23, 2021
Hi @eknudsen :wave: - 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```

This worked perfectly @mhouston, thank you!