python-twitter
python-twitter copied to clipboard
Example code of OAuth2 with public client temporary tokens
Hi all,
Thanks for all the work on this module.
I have created an example of using the module with OAuth2 public clients. The example code is here in a gist.
The script itself will 'Unlike' all of a user's liked Tweets. So run as-is with caution.
The interesting bit is the WrappedPyTwitterAPI subclass of pytwitter.Api.
The example will handle a few things I did not see in other examples
- capturing the OAuth2 callback from inside the app
- refreshing access tokens that Public Client apps get when they expire
- detecting errors that can be recovered from, such as Rate Limit exceeded and token expired.
Hope this is helpful.