Python requests library how to pass Authorization header with single token

后端 未结 8 1112
暗喜
暗喜 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:24

    This worked for me:

    r = requests.get('http://127.0.0.1:8000/api/ray/musics/', headers={'Authorization': 'Token 22ec0cc4207ebead1f51dea06ff149342082b190'})
    

    My code uses user generated token.

提交回复
热议问题