4

I'm trying to post a tweet using Twython from Django-powered site. However, the 'twitter.updateStatus(status=tweet_text)' line results in the following error:

TwythonError: u'Unauthorized: Authentication credentials were missing or incorrect. -- Invalid / expired Token'

I do have requests version 0.13.9, so this shouldn't be an issue:

>>>import pkg_resources
>>>pkg_resources.get_distribution("requests").version
'0.13.9'
>>>pkg_resources.get_distribution("twython").version
'2.3.4'

Any idea how to fix this? Thanks in advance!

Here's the python method itself:

def tweet_link(request, tweet_text):
    try:
        c = RequestContext(request)
        twitter = Twython(
            twitter_token = TWITTER_KEY,
            twitter_secret = TWITTER_SECRET,
            oauth_token = request.session['request_token']['oauth_token'],
            oauth_token_secret = request.session['request_token']['oauth_token_secret']
        )
        twitter.updateStatus(status=tweet_text)
    except Exception, e:
        print traceback.print_exc()
    return HttpResponse('')
Arman
  • 1,074
  • 3
  • 20
  • 40

1 Answers1

2

I'm the author of Twython.

This bug was occurring due to an issue with a dependency we have (Requests), which has been fixed as of Requests v0.13.9. It should be fine now; do feel free to contact me if not.

Ryan McGrath
  • 2,042
  • 14
  • 23
  • Hey Ryan, thanks for a reply. I just recloned twython again, restarted apache, but still get the same error - TwythonError: u'Unauthorized: Authentication credentials were missing or incorrect. -- Invalid / expired Token'. Am I missing something? Thanks in advance! – Arman Aug 26 '12 at 22:14
  • 1
    And I have Requests v0.13.9 (python2.7/site-packages/requests-0.13.9-py2.7.egg), just checked. – Arman Aug 27 '12 at 19:32