Python requests library how to pass Authorization header with single token

后端 未结 8 1110
暗喜
暗喜 2020-12-02 14:02

I have a request URI and a token. If I use:

curl -s \"\" -H \"Authorization: TOK:\"

etc., I get a 200 and vie

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 14:47

    I was looking for something similar and came across this. It looks like in the first option you mentioned

    r = requests.get('', auth=(''))
    

    "auth" takes two parameters: username and password, so the actual statement should be

    r=requests.get('', auth=('', ''))
    

    In my case, there was no password, so I left the second parameter in auth field empty as shown below:

    r=requests.get('

    Hope this helps somebody :)

提交回复
热议问题