Python-oauth2 with Twitter oauth_callback

I use Twython as my twitter API shell and oauth2 for authentication. I try to use the login via twitter, and then redirect it after the oauth dance to the dynamically generated oauth_callback. However, this seems to be impossible to do with these libraries right out of the box. My problem is that my oauth client (python-oauth2) does not support callbacks. I find this very strange because it is the default oauth client used by Twython - why would they write code to host a dynamic callback and then link the library to an oauth client that does not support callbacks? Line 54 is set to false , so my callback url is never included in the request token url, as required by oAuth 1.0a specifications .

I tried modifying both Twython and oauth2, but I have problems all the time. I would like to know if there is an alternative python-oauth2 that supports oauth_callback or maybe an alternative Twitter library that will handle oauth correctly.

+4
source share
1 answer

Found the answer here

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

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

Note that if you want Twitter to respect your oauth_callback argument, the request must be POST.

+9
source

All Articles