Introductie tot API's in Python
Chris Ramakers
Engineering Manager


| Methode | Implementatiegemak | Beveiliging |
|---|---|---|
| Basic authentication | ⭐ ⭐ ⭐ ⭐ ⭐ | ⭐ ☆ ☆ ☆ ☆ |
| API-sleutel/-token | ⭐ ⭐ ⭐ ⭐ ☆ | ⭐ ⭐ ☆ ☆ ☆ |
| JWT-authenticatie | ⭐ ⭐ ⭐ ☆ ☆ | ⭐ ⭐ ⭐ ⭐ ☆ |
| OAuth 2.0 | ⭐ ⭐ ☆ ☆ ☆ | ⭐ ⭐ ⭐ ⭐ ⭐ |
Tip: check de API-documentatie om te zien welke authenticatiemethode je moet gebruiken!

# Voegt automatisch een Basic Authentication-header toe vóór het verzenden
requests.get('http://api.music-catalog.com', auth=('username', 'password'))
http://api.music-catalog.com/albums?access_token=faaa1c97bd3f4bd9b024c708c979feca
params = {'access_token': 'faaa1c97bd3f4bd9b024c708c979feca'}
requests.get('http://api.music-catalog.com/albums', params=params)

headers = {'Authorization': 'Bearer faaa1c97bd3f4bd9b024c708c979feca'}
requests.get('http://api.music-catalog.com/albums', headers=headers)
Introductie tot API's in Python