Tweepy: TweepError: 'Bad Authentication Data' code 215


#1

OAuth has cost me 10 wasted hours so far and continues to make my life an existential hell.

I am trying to use the Twitter API with Google App Engine. There seems to be precious little that will work on that particular platform because of Google’s aversion to third party libraries, or package dependencies, or what have you.

Tweepy is one I’ve been trying, but it doesn’t authenticate.

Here’s the “Inspect Network Request” data from my web console, FWIW:

//////////////////////////////////////////////////////////////////////////////////////////

POST http://localhost:9082/tweet [HTTP/1.1 500 Internal Server Error 1084ms]

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:20.0) Gecko/20100101 Firefox/20.0
Referer:http://localhost:9082/tweet
Host:localhost:9082
Connection:keep-alive
Accept-Language:en-US,en;q=0.5
Accept-Encoding:gzip, deflate
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

Sent Cookie
user-id:[xxxxxxxxxxx]
csrftoken:[also redacted]

Server:Development/2.0
Expires:Fri, 01 Jan 1990 00:00:00 GMT
Date:Wed, 15 May 2013 09:28:47 GMT
Content-Type:text/html
Content-Length:0
Cache-Control:no-cache

//////////////////////////////////////////////////////////////////////////////////////////

The program throws a stack trace in the Google App Engine Launcher console and I get the message “TweepError: [{u’message’: u’Bad Authentication data’, u’code’: 215}]”

  1. Does anyone here successfully authenticate on App Engine with Python ? Do you use a Twitter API library, or do you roll your own methods?

  2. IDK, maybe I will need to use an OAuth library for App Engine that doesn’t integrate the Twitter API. Which I don’t know how to do. Wouldn’t that force me to tailor my own HTTP request headers and do tons of work?

Forgive me if these are stupid questions, please. I’m at my wit’s end.


#2

I realized that the HTTP Header I included is probably not helpful because my program (via App Engine Launcher server on my localhost) is what sends the OAuth requests (using Tweepy), upon sending a POST request (the included header). But if there’s some more information I can send that will help, please do let me know and I’ll do my best.

Many thanks.


#3

I use:
if os.environ.get(‘SERVER_SOFTWARE’, ‘’).startswith(‘Dev’):
CALLBACK = 'http://127.0.0.1:8080/oauth/callback
else:
CALLBACK = ‘http://yourapp.appspot.com/oauth/callback