Making custom REST requests using authenticated session

41 views
Skip to first unread message

Tom Himanen

unread,
Jun 16, 2015, 7:14:45 PM6/16/15
to python-...@googlegroups.com
Since there isn't for example favorite creation feature implemented, is it possible to send a custom REST request through authenticated OAUTH session? If not, would it be possible to have an opportunity to utilize the authenticated session for talking with the server through REST API "manually"? Thanks for this great library! Cheers!

bear

unread,
Jun 16, 2015, 7:24:44 PM6/16/15
to python-...@googlegroups.com, tom.h...@gmail.com
Yep!

The library uses a shared routine to make all of the actual calls - you can see it in action by looking at the source for say "PostMedia" https://github.com/bear/python-twitter/blob/master/twitter/api.py#L901

At line 937 we build the Twitter API request url
Lines 939 - 963 are all building the data dictionary that will become the request parameters
Line 965 is where the request is made using the current authenticated session - the return value is the raw json blob that Twitter's API sends back

So you should be able to call _RequestUrl(url, verb, data) just like any other python-twitter api call.
Reply all
Reply to author
Forward
0 new messages