Today while reading about mining Twitter Data, I got the below script and it worked great. Before you can start please make sure that you have created an application in the Below Twitter App link and then get the consumer key, secret and App name to be used with the script. Set those details in the conf.toml folder.

Installation

Make sure you have latest toml & twitter module installed. Next once run the script twitter_oauth.py after which a window will come up to authorize your app and once you authorize the app it show a screen with a pin, copy that and paste in command line at a prompt to provide the pin. Once done you will see that a new file is created in a out folder called twitter.oauth. And now next time when ever you try to login it will check the existence of that file and use it for authentication.

The code details are given below:

For any feedback please contact me via twitter: