4

I'm using Twython as my Twitter API wrapper, and oauth2 to handle authentication. I'm trying to have a use login via twitter, and then redirecting him after the oauth dance to a dynamically generated oauth_callback. This, however, appears to be impossible to do with these libraries straight out of the box. My problem is that my oauth client (python-oauth2), doesnt support callback urls. I find this very strange because this is the default oauth client used by Twython -- why would they bother writing code to accomodate the use of a dynamic callback and then bundle the library with an oauth client that doesn't support callbacks? Line 54 is set to false, therefore my callback url is never included in the request token url, as required in the oAuth 1.0a specs.

I've tried modifying both Twython and oauth2, but I keep running into problems. I'd like to know if there is an alternative to python-oauth2 that supports oauth_callback, or maybe an alternative twitter library that would handle the oauth properly.

D-Nice
  • 4,772
  • 14
  • 52
  • 86
  • 1
    Hey there! I'm the author of Twython - this is a good issue to fix; as I noted in another comment on this thread, I'll patch it up later and release it. Thanks! – Ryan McGrath May 23 '11 at 09:10
  • I'm glad to be of use. Thanks for the great work on Twython! – D-Nice May 23 '11 at 23:35

1 Answers1

10

Found the answer here

All you have to do is pass Twython the parameter callback_url and replace line 205 in Twython.py with

resp, content = client.request(request_token_url, "POST",body=urllib.urlencode({'oauth_callback':my_callback_url}))

Notice, if you want twitter to respect your oauth_callback argument, the request must be a POST.

D-Nice
  • 4,772
  • 14
  • 52
  • 86
  • 2
    Hey there! I'm the author of Twython - this is a nice find, I'll add a patch in later this week to fix it right up! ;) – Ryan McGrath May 23 '11 at 09:10