0

I have subscribed to an API which gave me an authorization token and the following curl command:

curl -X GET --header "Accept: application/json" --header "Authorization: Bearer 37d5a9ac5442ba9f594a8ca1421a27b" "https://blah/blah/blah"

This curl works in terminal and returns some json when I run it. Now I need to work with the returned json so I wanted to either do this request in JS or python. Here's my python attempt:

url = "https://blah/blah/blah"
headers = {
    "Accept": "application/json",
    "Authentication": "Bearer 37d5a9ac5442ba9f594a8ca1421a27b"
}
response = requests.get(url, headers=headers)
print(response.text)

This responds with:

{"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\""}}

What am I doing wrong? I don't have an explicit username and password like other answers to similar questions suggest.

4
  • Executing the curl statement resulted in a 200 OK being returned from the server? Commented Feb 22, 2017 at 18:33
  • 1
    curl.trillworks.com Commented Feb 22, 2017 at 18:37
  • @kkaosninja The curl statement prints the expected json so I'm assuming the status code is 200. Commented Feb 22, 2017 at 18:42
  • @IanD I believe sideshowbarker's answer should solve your problem :-) Commented Feb 23, 2017 at 6:41

1 Answer 1

2

The error message says your request needs to include a header named Authorization.

But your Python code snippet instead has a request with the header name Authentication.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.