Exemplo n.º 1
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ''
    CONSUMER_KEY = '2JRLM23QHyLyBABuqg4tqQ'
    CONSUMER_SECRET = 'avpoP356DDKbHtTRiicjKBC01yXqfaI8QCgfZebmjA'
    TOKEN_FILE = 'auth/twitter.oauth'

    '''
        consumer_key = '2JRLM23QHyLyBABuqg4tqQ'
        consumer_secret = 'avpoP356DDKbHtTRiicjKBC01yXqfaI8QCgfZebmjA'
        access_token = '20692466-4kkQfaO8V0e2cVBDzfYg4EkFdQO9u0CNZLoP8Xma5'
        access_token_secret = '0bUGan28R0Dt2f0NIIjA2AcCkNUelANx674aWUH9Oj08f'
    '''
    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('auth'):
            os.mkdir('auth')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
def login_and_get_twitter():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    CREDENTIALS_FILE = './twitter_credentials.txt'
    TOKEN_FILE = './twitter_token.oauth'  # in the current directory
#     try:
    (app_name, consumer_key, consumer_secret) = read_credentials_file(CREDENTIALS_FILE)
#     except IOError:
#         print(TOKEN_FILE + " not found")
    
    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
        logging.info('read token from file success')
    except IOError as e:
        logging.info('read token from file failed, requesting new token')
        (oauth_token, oauth_token_secret) = oauth_dance(app_name, consumer_key,
                consumer_secret)
  
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)

    return twitter.Twitter(domain='api.twitter.com', api_version='1.1',
                        auth=twitter.oauth.OAuth(oauth_token, oauth_token_secret,
                        consumer_key, consumer_secret))
Exemplo n.º 3
0
def oauth_url_dance(
    consumer_key, consumer_secret, callback_url, oauth_verifier, pre_verify_token_filename, verified_token_filename
):
    # Verification happens in two stages...

    # 1) If we haven't done a pre-verification yet... Then we get credentials
    # from Twitter that will be used to sign our redirect to them, find the
    # redirect, and instruct the Javascript that called us to do the redirect.
    if not os.path.exists(CREDS_PRE_VERIFIY):
        twitter = Twitter(auth=OAuth("", "", consumer_key, consumer_secret), format="", api_version=None)
        oauth_token, oauth_token_secret = parse_oauth_tokens(twitter.oauth.request_token(oauth_callback=callback_url))
        write_token_file(pre_verify_token_filename, oauth_token, oauth_token_secret)

        oauth_url = "https://api.twitter.com/oauth/authorize?" + urllib.urlencode({"oauth_token": oauth_token})
        return oauth_url

    # 2) We've done pre-verification, hopefully the user has authed us in
    # Twitter and we've been redirected to. Check we are and ask for the
    # permanent tokens.
    oauth_token, oauth_token_secret = read_token_file(CREDS_PRE_VERIFIY)
    twitter = Twitter(
        auth=OAuth(oauth_token, oauth_token_secret, consumer_key, consumer_secret), format="", api_version=None
    )
    oauth_token, oauth_token_secret = parse_oauth_tokens(twitter.oauth.access_token(oauth_verifier=oauth_verifier))
    write_token_file(verified_token_filename, oauth_token, oauth_token_secret)
    return oauth_token, oauth_token_secret
Exemplo n.º 4
0
def login():

    config = ConfigParser.ConfigParser()
    config.readfp(open("twitter.config","rb"))

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = config.get('account', 'appname')
    CONSUMER_KEY = config.get('account', 'consumerkey')
    CONSUMER_SECRET = config.get('account', 'consumersecret')
    ACCESS_TOKEN = config.get('account', 'accesstoken')
    ACCESS_TOKEN_SECRET = config.get('account', 'accesstokensecret')
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        if ACCESS_TOKEN != None and ACCESS_TOKEN_SECRET != None:
            oauth_token = ACCESS_TOKEN
            oauth_token_secret = ACCESS_TOKEN_SECRET
        else:
            (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 5
0
def ipynb_oauth_dance():
    _twitter = twitter.Twitter(auth=twitter.OAuth("", "", CONSUMER_KEY, CONSUMER_SECRET), format="", api_version=None)
    oauth_token, oauth_token_secret = parse_oauth_tokens(_twitter.oauth.request_token(oauth_callback=oauth_callback))
    # Need to write these interim values out to a file to pick up on the callback
    # from Twitter that is handled by the web server in /oauth_helper
    write_token_file(OAUTH_FILE, oauth_token, oauth_token_secret)
    oauth_url = "http://api.twitter.com/oauth/authorize?oauth_token=" + oauth_token
    # Tap the browser's native capabilities to access the web server through a new
    # window to get user authorization
    display(JS("window.open('%s')" % oauth_url))
Exemplo n.º 6
0
def get_twitter_stream():

	try:
		(oauth_token, oauth_token_secret)= read_token_file(token_file)
	except IOError, e:
		(oauth_token, oauth_token_secret)=oauth_dance (app_name, consumer_key, consumer_secret)

		if not os.path.isdir(token_path):
			os.mkdir(token_path)
	
		write_token_file(token_file, oauth_token, oauth_token_secret)
def oauth_login(app_name=APP_NAME,consumer_key=CONSUMER_KEY,consumer_secret=CONSUMER_SECRET,token_file='out/twitter_oauth'):

	try:
		(oauth_token, oauth_token_secret) = read_token_file(token_file)
	except IOError, e:
		(oauth_token, oauth_token_secret) = oauth_dance('deathcape', consumer_key, consumer_secret)

		if not os.path.isdir('out'):
			os.mkdir('out')
		write_token_file(token_file,oatuh_token,oauth_token_secret)
		print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Exemplo n.º 8
0
def oauth_login(app_name="", consumer_key="", consumer_secret="", token_file="out/twitter.oauth"):
    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key, consumer_secret)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(token_file, access_token, access_token_secret)

        print >> sys.stderr, "OAuth Success. Token file stored to", token_file

    return twitter.Twitter(domain='api.twitter.com', api_version='1', auth=twitter.oauth.OAuth(access_token, access_token_secret, consumer_key, consumer_secret))
Exemplo n.º 9
0
def oauth_login(app_name=APP_NAME,
                consumer_key=CONSUMER_KEY, 
                consumer_secret=CONSUMER_SECRET, 
                token_file='auth/twitter.oauth'):

    # try to read the token file
    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e: # if it fails, create the token and write it to disk
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,
                                                          consumer_secret)
        if not os.path.isdir('auth'):
            os.mkdir('auth')
        write_token_file(token_file, access_token, access_token_secret)
        print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Exemplo n.º 10
0
def oauth_helper():
    oauth_verifier = request.args.get("oauth_verifier")
    # Pick back up credentials from ipynb_oauth_dance
    oauth_token, oauth_token_secret = read_token_file(OAUTH_FILE)
    _twitter = twitter.Twitter(
        auth=twitter.OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMER_SECRET), format="", api_version=None
    )
    oauth_token, oauth_token_secret = parse_oauth_tokens(_twitter.oauth.access_token(oauth_verifier=oauth_verifier))
    # This web server only needs to service one request, so shut it down
    shutdown_after_request = request.environ.get("werkzeug.server.shutdown")
    shutdown_after_request()
    # Write out the final credentials that can be picked up after the following
    # blocking call to webserver.run().
    write_token_file(OAUTH_FILE, oauth_token, oauth_token_secret)
    return "%s %s written to %s" % (oauth_token, oauth_token_secret, OAUTH_FILE)
def oauth_login(
    app_name=APP_NAME, consumer_key=CONSUMER_KEY, consumer_secret=CONSUMER_SECRET, token_file="out/twitter.oauth"
):

    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key, consumer_secret)

        if not os.path.isdir("out"):
            os.mkdir("out")

        write_token_file(token_file, access_token, access_token_secret)

        print >>sys.stderr, "OAuth Success. Token file stored to", token_file
Exemplo n.º 12
0
def py_oauth_dance():
    
    _twitter=twitter.Twitter(auth=twitter.OAuth('','',CONSUMER_KEY, CONSUMET_SECRET), format='', api_version=None)
    
    oauth_token, oauth_token_secret = parse_oauth_tokens(_twitter.oauth.request_token(oauth_callback=oauth_callback))
    
    # Se nececitan escribir estos valores en un archivo para de ahi recojer la 
    # llamada de Twitter que es manejada del web server en /oauth_helper
    
    write_token_file(OAUTH_FILE,oauth_token, oauth_token_secret)
    
    oauth_url=('http://api.twitter.com/oauth/authorize?oauth_token='+oauth_token)
    
    #Utilizamos el browser para abrir una nueva ventana y asi accesar al web 
    #server y obtener la autorizacion del usuario
    display(JS("windows.open('%s')" % oauth_url))
Exemplo n.º 13
0
def login():

    APP_NAME = 'Learning Python - Mining'
    CONSUMER_KEY = consumer_key
    CONSUMER_SECRET = consumer_secret
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = "ContatoSalvo"
    CONSUMER_KEY = "WwE7cxlLi7FsmyWRKSx17A"
    CONSUMER_SECRET = "2YQk2bW98LxcKRCUOicnWWg1tZUukSFwMZqX1MLxT3k"
    TOKEN_FILE = "out/twitter.oauth"

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY, CONSUMER_SECRET)
        if not os.path.isdir("out"):
            os.mkdir("out")
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 15
0
    def openAuthPage(self):

        """Method to open the web page which gives the PIN code for
        authentication. When done, verify the pin code and write the
        keys into a local file. The user won't have to do the dance each
        time he wants to tweet"""

        twitter = Twitter(auth=OAuth('', '', self.CONSUMER_KEY, self.CONSUMER_SECRET), format='', api_version=None)

        token, token_secret = self.parseOauthTokens(twitter.oauth.request_token(oauth_callback="oob"))

        self.l.debug("Opening authentication URL")

        oauth_url = ('https://api.twitter.com/oauth/authorize?oauth_token=' + token)

        try:
            r = webbrowser.open(oauth_url)

            # Sometimes the last command can print some
            # crap. Wait a bit so it doesn't mess up the next
            # prompt.
            time.sleep(2)

            if not r:
                raise Exception()
        except Exception as e:
            QtGui.QMessageBox.critical(self, "Authentication", "ChemBrows could not open a web page.\nVisit oauth_url to get the PIN code",
                                       QtGui.QMessageBox.Ok, defaultButton=QtGui.QMessageBox.Ok)
            self.l.error("Authentication URL not opened")
            self.l.error("openAuthPage: {}".format(e))
            self.l.error(traceback.format_exc())


        pin = QtGui.QInputDialog.getText(self, "PIN verification", "Enter the PIN to authenticate yourself")

        oauth_verifier = pin[0]

        twitter = Twitter(auth=OAuth(token, token_secret, self.CONSUMER_KEY, self.CONSUMER_SECRET), format='', api_version=None)

        oauth_token, oauth_secret = self.parseOauthTokens(twitter.oauth.access_token(oauth_verifier=oauth_verifier))

        self.l.debug("Writing authentication file")
        write_token_file(self.MY_TWITTER_CREDS, oauth_token, oauth_secret)

        self.twitter = Twitter(auth=OAuth(oauth_token, oauth_secret,
                               self.CONSUMER_KEY, self.CONSUMER_SECRET))
Exemplo n.º 16
0
def login():
    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'SocialWebJuanPavez'
    CONSUMER_KEY = 'XTtlNpLJRamXyuJOvX1g'
    CONSUMER_SECRET = 'O8oHQ3Yn2KCIUDnlMv7MmbKOZP82qpY43ITMh5kQmE'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY, CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 17
0
def login():

	APP_NAME = ''
	CONSUMER_KEY = ''
	CONSUMER_SECRET = ''
	TOKEN_FILE = '         '

	try:
		(oauth_token, oauth_token_secret) = read_token_file('auth/twitter.oauth')

	except IOError, e :
		(oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY, CONSUMER_SECRET)

		if not os.path.isdir('auth'):
			os.mkdir('auth')

		write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 18
0
def oauth_login(app_name='',
                consumer_key='', 
                consumer_secret='', 
                token_file='out/twitter.oauth'):

    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,
                consumer_secret)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(token_file, access_token, access_token_secret)

        print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Exemplo n.º 19
0
def login():
    #loging to twitter application
    APP_NAME = "Finance_Harvest"
    CONSUMER_KEY = "Bkvk7JFZmzaVpLjGAWBtxQ"
    CONSUMER_SECRET = "y9tugnYJeU8aMNW44o6hwWHC3QVktCYtW3RDm3Mdk"
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        print e.errno, e.strerror
        (oauth_token, oauth_token_secret) = oauth_dance(
            APP_NAME, CONSUMER_KEY, CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')
        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
def authenticate(app_name="", consumer_key="", consumer_secret="", token_file="auth/twitter.oauth"):
    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError:
        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key, consumer_secret)

        if not os.path.isdir("auth"):
            os.mkdir("auth")

        write_token_file(token_file, access_token, access_token_secret)

        print "OAuth Success. Token file stored to ", token_file
    # Connect to Twitter
    return twitter.Twitter(
        domain="api.twitter.com",
        api_version="1.1",
        auth=twitter.oauth.OAuth(access_token, access_token_secret, consumer_key, consumer_secret),
    )
Exemplo n.º 21
0
def oauth_helper():
    
    oauth_verifier=request.args.get('oauth_verifier')
    
    #Recojer credenciales de respaldo
    oauth_token, oauth_token_secret=read_token_file(OAUTH_FILE)
    
    _twitter=twitter.Twitter(auth=twitter.OAuth(oauth_token, oauth_token_secret, CONSUMER_KEY, CONSUMET_SECRET), format='', api_version=None)
    
    oauth_token, oauth_token_secret=parse_oauth_tokens(_twitter.oauth.access_token(oauth_verifier=oauth_verifier))
    
    #Este web server solo necesita servir una peticion, asi que se apaga
    shutdown_after_request=request.environ.get('werkzeug.server.shutdown')
    shutdown_after_request()
    
    #Se escriben las credenciales 
    write_token_file(OAUTH_FILE, oauth_token, oauth_token_secret)
    return "%s %s se escribio en %s" % (oauth_token, oauth_token_secret, OAUTH_FILE)
Exemplo n.º 22
0
def login():
    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'bigrams'
    CONSUMER_KEY = 'pqVYCCTqqDq3WSrwuAaesw'
    CONSUMER_SECRET = 'kvG6OTTvYt6j1rXS34083u9vS0skTSbOCsVImGRWU'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                                                        CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 23
0
def oauth_login(app_name=APP_NAME,
                consumer_key=CONSUMER_KEY, 
                consumer_secret=CONSUMER_SECRET, 
                token_file='out/twitter.oauth'):

    try:
        (access_token, access_token_secret) = read_token_file(token_file)
    except IOError, e:
#        (access_token, access_token_secret) = oauth_dance(app_name, consumer_key,
#                consumer_secret)

        access_token = '894521209-crya1bTHnzRqk4QtpgwX64lEA00coewp3g9QPXes'
        access_token_secret = 'HtaEUBtUWAjS9JBbBaJLlMYJk5mpaRII6YhWAljebw'
        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(token_file, access_token, access_token_secret)

        print >> sys.stderr, "OAuth Success. Token file stored to", token_file
Exemplo n.º 24
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ""
    CONSUMER_KEY = ""
    CONSUMER_SECRET = ""
    TOKEN_FILE = "out/twitter.oauth"

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY, CONSUMER_SECRET)

        if not os.path.isdir("out"):
            os.mkdir("out")

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = '' # no app name - still works
    CONSUMER_KEY = 'dafFn7vDnNmQC0mlWjhSA'
    CONSUMER_SECRET = '38AdsbwgcLOcX6XXThShihNcb2MpCpHheplw2Q4Tw'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 26
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'vozome'
    CONSUMER_KEY = 'ppHAC64cJGBBlwIx9ES4fw'
    CONSUMER_SECRET = 'P6DfN32vTZDkSZfglYryXWStT3xJaOKaRUz8SszHQ'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 27
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'innovation odds'
    CONSUMER_KEY = '0symlgCIKrr4W3J7LAIF8g'
    CONSUMER_SECRET = 'mCu4CAYJdGHz0k5xFiXoOxIZGC7hgJpfaCHsO9kA3o'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 28
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'pymob'
    CONSUMER_KEY = 'PxfHAjKFj1gLrpoxVj4GFw'
    CONSUMER_SECRET = 'Ty2AZmC9Q2ML3LBOHA1KS2WwIWPYkVT9FoUuZrDU2k'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 29
0
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'QMBlogging'
    CONSUMER_KEY = '6Zh1OZGtpQgTENiRDpY4zg'
    CONSUMER_SECRET = 'KIyMtMEuMMaU12HNEtM2G3x23Jge5yy1kxSKeeBPYvU'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = 'arunapp' # app I created
    CONSUMER_KEY = 'fPnTbRpK2l6vIPw9agJA'
    CONSUMER_SECRET = 'RJdDoZ4ZTvSi4AggFV0OjSqkh9Z9i4AtS80QD2xb4'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)
Exemplo n.º 31
0
def login():

    c = config.Config()
    d = c.cfg
    
    app_name = d.get('twitter', 'app_name')
    consumer_key = d.get('twitter', 'consumer_key')
    consumer_secret = d.get('twitter', 'consumer_secret')
    token_file = d.get('twitter', 'token_file')

    try:
        (oauth_token, oauth_token_secret) = read_token_file(token_file)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(app_name, consumer_key,
                consumer_secret)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(token_file, oauth_token, oauth_token_secret)
def login():

    # Go to http://twitter.com/apps/new to create an app and get these items
    # See also http://dev.twitter.com/pages/oauth_single_token

    APP_NAME = ''
    CONSUMER_KEY = 'SKxOLVcsxlPN68V3g2hAA'
    CONSUMER_SECRET = 'jBc0MUUNebHiIEkkraM7IruUyoSY2OZZyZ7eW6qqYw'
    TOKEN_FILE = 'out/twitter.oauth'

    try:
        (oauth_token, oauth_token_secret) = read_token_file(TOKEN_FILE)
    except IOError, e:
        (oauth_token, oauth_token_secret) = oauth_dance(APP_NAME, CONSUMER_KEY,
                CONSUMER_SECRET)

        if not os.path.isdir('out'):
            os.mkdir('out')

        write_token_file(TOKEN_FILE, oauth_token, oauth_token_secret)