0
所以我對web dev很陌生,所以對我一無所知。我已經訂閱這給了我一個授權令牌的API和下面的curl命令:將curl命令轉換爲python獲取請求
curl -X GET --header "Accept: application/json" --header "Authorization: Bearer 37d5a9ac5442ba9f594a8ca1421a27b" "https://blah/blah/blah"
這捲曲工作在終端,當我運行它返回一些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\""}}
我在做什麼錯?我沒有一個明確的用戶名和密碼,就像其他類似問題的答案一樣。
執行curl語句導致從服務器返回200 OK? – kkaosninja
https://curl.trillworks.com/ –
@kkaosninja curl語句打印預期的json,所以我假設狀態代碼是200. –