0

In my callback handler from twitter, I cannot seem to make a httplib POST request as it throws an unrelated 401 Token Invalid Expired error. I'm using Google App Engine and have tried the urlfetch function as well.

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
conn = httplib.HTTPConnection(create_url)
conn.request("POST", "", form_data, headers)
response = conn.getresponse()
if response.status == 500: 
    # do stuff

Matching error log: Twitter API returned a 401 (Unauthorized), Invalid / expired To ken

ldz
  • 2,217
  • 16
  • 21
user1961
  • 1,270
  • 2
  • 17
  • 27

1 Answers1

0

The solution was to use the Requests library for the POST request. For some unknown reason neither httplib or urlfetch work in the twittercallback endpoint on Google App Engine.

user1961
  • 1,270
  • 2
  • 17
  • 27