Python Queries - Auth Token

I am using Python Requests 2.7.0 and I am trying to pass an authtoken for a session. I can successfully connect using session.auth(user,pass) , but I am not familiar with how to pass authtoken to the session.

I tried using the headers for the session, but that didn't work. Here is the general flow of what I have:

 session = requests.Session() session.headers.update({'Authorization': TOKEN}) ... 
+6
source share
1 answer

You correctly set the header that will be used for all requests sent with the session.

You probably aren't setting a header value. The Authorization header should probably follow a specific pattern, as indicated in the documentation for the service you are communicating with. Typically, the value must begin with an authentication scheme (for example, Basic and Digest authentication schemes , so the value will be <scheme> <token> .

+4
source

Source: https://habr.com/ru/post/987514/


All Articles