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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With