#!/usr/bin/env python3

import twython
import subprocess

from config import Config

def main():
    """This is a script to get the oauth tokens for the bot"""

    twitter = twython.Twython(Config.CONSUMER_KEY, Config.CONSUMER_SECRET)
    auth = twitter.get_authentication_tokens()

    try:
        subprocess.check_call(['open', auth['auth_url']])
    except Exception as e:
        print('Could not open browser.\nPlease go to {0} and authorize '
              'the application enter the PIN provided by Twitter to complete '
              'the token generation process'.format(auth['auth_url']))

    print('PIN: ', end='')
    pin = input()
    if not pin.isdigit():
        print("PIN must be a number")
        exit(1)

    twitter = twython.Twython(Config.CONSUMER_KEY, Config.CONSUMER_SECRET,
        auth['oauth_token'], auth['oauth_token_secret'])
    tokens = twitter.get_authorized_tokens(pin)

    print('OAUTH_TOKEN = \'{0}\''.format(tokens['oauth_token']))
    print('OAUTH_TOKEN_SECRET = \'{0}\''.format(tokens['oauth_token_secret']))

if __name__ == '__main__':
    main()

@@ -28,33 +28,32 @@
 ort 
-twython%0Aimport subprocess
+subprocess%0Aimport tweepy
 %0A%0Afr
@@ -161,33 +161,34 @@
     
-twitter = twython.Twython
+auth = tweepy.OAuthHandler
 (Con
@@ -237,26 +237,27 @@
     auth
- = twitter
+_url = auth
 .get_aut
@@ -261,25 +261,21 @@
 auth
-entic
+oriz
 ation_
-tokens
+url
 ()%0A%0A
@@ -322,30 +322,24 @@
 'open', 
-auth%5B'
 auth_url
 '%5D%5D)%0A   
@@ -330,18 +330,16 @@
 auth_url
-'%5D
 %5D)%0A    e
@@ -718,119 +718,29 @@
     
-twitter = twython.Twython(Config.CONSUMER_KEY, Config.CONSUMER_SECRET,%0A        auth%5B'oauth
+(access
 _token
-'%5D
 , a
-uth%5B'oauth
+ccess
 _tok
@@ -752,54 +752,33 @@
 cret
-'%5D)%0A    tokens = twitter.get_authorized
+) = auth.get_access
 _token
-s
 (pin
@@ -825,29 +825,20 @@
 mat(
-tokens%5B'oauth
+access
 _token
-'%5D
 ))%0A 
@@ -888,21 +888,14 @@
 mat(
-tokens%5B'oauth
+access
 _tok
@@ -903,18 +903,16 @@
 n_secret
-'%5D
 ))%0A%0Aif _

Switch get_oauth_token.py to tweepy