python request with authentication (access_token)

后端 未结 5 2105
别跟我提以往
别跟我提以往 2020-11-28 06:00

I am trying to get an API query into python. The command line

curl --header \"Authorization:access_token myToken\" https://website.com/id

g

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 06:35

    I had the same problem when trying to use a token with Github.

    The only syntax that has worked for me with Python 3 is:

    import requests
    
    myToken = ''
    myUrl = ''
    head = {'Authorization': 'token {}'.format(myToken)}
    response = requests.get(myUrl, headers=head)
    

提交回复
热议问题