我订阅了一个API,它给了我一个授权令牌和以下curl命令:
curl -X GET --header "Accept: application/json" --header "Authorization: Bearer 37d5a9ac5442ba9f594a8ca1421a27b" "https://blah/blah/blah"
此curl在终端中工作,并在运行时返回一些json。现在我需要使用返回的json,所以我想在JS或python中执行此请求。这是我的python尝试:
url = "https://blah/blah/blah"
headers = {
"Accept": "application/json",
"Authentication": "Bearer 37d5a9ac5442ba9f594a8ca1421a27b"
}
response = requests.get(url, headers=headers)
print(response.text)
回复:
{"fault":{"code":900902,"message":"Missing Credentials","description":"Required OAuth credentials not provided. Make sure your API invocation call has a header: \"Authorization: Bearer ACCESS_TOKEN\""}}
我做错了什么?我没有像其他类似问题的答案那样明确的用户名和密码。