Authentication mechanisms with Python
Most of the web services that we use today require some authentication mechanism in order to ensure the user’s credentials are valid to access them.
In this section, we’ll learn how to implement authentication in Python. The HTTP protocol natively supports three authentication mechanisms:
- HTTP basic authentication: Transmits a user/password pair as a
base64
encoded string. - HTTP digest authentication: This mechanism uses MD5 to encrypt the user, key, and realm hashes.
- HTTP bearer authentication: This mechanism uses authentication based on
access_token
. One of the most popular protocols that use this type of authentication is OAuth. In the following URL, we can find the different Python libraries supported by this protocol: https://oauth.net/code/python/.
Python supports both mechanisms through the requests
module. However, the main difference between both methods is that basic only encodes without...