Sometimes you might want to authenticate against an API with username and password where examples are only listed with curl:
curl -u username:password https://127.0.0.1/foobar
If you want to implement the same in python you can use the following
from requests.auth import HTTPBasicAuth
username = "username"
password = "password"
request_url = "https://127.0.0.1/foobar"
result = requests.post(request_url, auth=HTTPBasicAuth(username, password))
Hope it helps, let me know