Error 400 Bad Request running app-only request



I am an amateur programmer trying to build a Python app that will print out all of the tweets from my user_timeline. I have been able to receive a bearer token but I am having difficulty receiving data when making my request. The documentation says that I do not need to sign this request but rather put the bearer token in the header under "Authorization : " when making the request. Unfortunately, when I do this, I receive an Error 400 Bad Request in response. I am sure I am missing something simple but any advice or guidance would be most appreciated.

Thanks in advance.

code example:

host = ''
url = '/1.1/statuses/user_timeline.json?count=100'
reqbear = httplib.HTTPSConnection(host)
reqbear.putrequest("GET", url)
reqbear.putheader("Host", host)
reqbear.putheader("Authorization", "Bearer%s" % base64.b64encode(bearer token))
reqbear.putheader("User-Agent", "Twittitron Five Thousand")
reqbear.putheader("Content-Type" ,"application/json")
reqbear.putheader("Content-Length", "140")
reqbear.putheader("Accept-Encoding", "json")


respbear = reqbear.getresponse()
beardate =
print respbear.status, respbear.reason
print beardate


It looks like you might be setting the Authorization header to “BearerACTUALTOKEN” instead of “Bearer ACTUALTOKEN”

Also, no need to set a Content-Type or Content-Length on a GET-based request.




I had tried it with both just to try to find something. I get the same response with a space there. Will setting the Content-Type and Length cause a 400?

Thanks for the response .