what am I doing wrong? I get 401
code
I use sites API, here is an example from the site:
My code:
import requests
login = "9163516566U1233"
password = "1233852"
get_url = "https://mrecord.mts.ru/api/v3/recs/9160551823/2019-07-24T00:00:00/2019-07-28T23:59:59"
b64_auth_str = "bG9naW46cGFzc3dvcmQ="
headers = {'Authorization': 'Basic %s' % b64_auth_str}
content_res = requests.get(get_url, headers=headers, auth=('login', 'password'))
print(content_res)
Output:
<Response [401]>
You are passing login
and password
as string. Is that right? I guess it should be
content_res = requests.get(get_url, headers=headers, auth=(login, password))
At least you have set the variables.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.