Úvod do API v Pythonu
Chris Ramakers
Engineering Manager


| Metoda | Snadnost implementace | Hodnocení zabezpečení |
|---|---|---|
| Základní autentizace | ⭐ ⭐ ⭐ ⭐ ⭐ | ⭐ ☆ ☆ ☆ ☆ |
| Autentizace API klíčem/tokenem | ⭐ ⭐ ⭐ ⭐ ☆ | ⭐ ⭐ ☆ ☆ ☆ |
| Autentizace JWT | ⭐ ⭐ ⭐ ☆ ☆ | ⭐ ⭐ ⭐ ⭐ ☆ |
| OAuth 2.0 | ⭐ ⭐ ☆ ☆ ☆ | ⭐ ⭐ ⭐ ⭐ ⭐ |
Tip: V dokumentaci používaného API zjistíte, kterou metodu autentizace použít!

# This will automatically add a Basic Authentication header before sending the request
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)
Úvod do API v Pythonu