I am using Python Requests 2.7.0, and I am trying to pass a authtoken for a Session. I am able to successfully connect using session.auth(user,pass)
, but I am unfamiliar with how to pass a authtoken into a session.
I tried using headers for the session, but this did not work. Here is the general flow of what I have:
session = requests.Session()
session.headers.update({'Authorization': TOKEN})
...
You are correctly setting a header to be used for all requests sent with the session.
You are probably not setting the header value correctly, however. The Authorization
header probably has to follow a specific pattern, as outlined in the documentation for the service you are contacting. It is typical that the value must start with a authentication scheme (like the Basic and Digest authentication schemes, so the value would be <scheme> <token>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With