How to use the tweepy.BasicAuthHandler function in tweepy

To help you get started, we’ve selected a few tweepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pschwede / AnchorBot / src / microblogger.py View on Github external
def send_text( self, text, url):
        if TWEEPY: # if installed
            uri = self.host.split( "/" )
            self.auth = tweepy.BasicAuthHandler( *self.__name_passwd )
            if len( uri ) > 1:
                api_root = "/" + "/".join( uri[1:] )
                self.client = tweepy.API( self.auth, uri[0], api_root=api_root, secure=True )
            else:
                self.client = tweepy.API( self.auth, uri[0], secure=True )
            self.client.update_status( u"" + text )
github tweepy / tweepy / tutorial / t1.py View on Github external
""" Tutorial 1 -- Authentication

Tweepy supports both basic auth and OAuth authentication. It is 
recommended you use OAuth so you can be more secure and also 
set a custom "from xxx" for you application.

Authentication is handled by AuthHandler instances. You must either
create a BasicAuthHandler or OAuthHandler which we will pass into our 
api instance to let twitter know who we are.

First let's try creating a basic auth handler.
"""
username = raw_input('Twitter username: ')
password = getpass('Twitter password: ')
basic_auth = tweepy.BasicAuthHandler(username, password)

"""
Now for an OAuth handler...

You must supply the handler both your consumer key and secret which
twitter supplies you with at http://twitter.com/oauth_clients
You may also supply a callback URL as an optional parameter.
"""
consumer_key = 'ZbzSsdQj7t68VYlqIFvdcA'
consumer_secret = '4yDWgrBiRs2WIx3bfvF9UWCRmtQ2YKpKJKBahtZcU'
oauth_auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
oauth_auth_callback = tweepy.OAuthHandler(consumer_key, consumer_secret,
                                            'http://test.com/my/callback/url')

"""
We must redirect the user to twitter so they can authorize us.
github tweepy / django-twango / twango / auth.py View on Github external
def get_site_auth():
    """Return auth handler for site API object"""

    # First check for basic auth credentials
    twitter_user = get_setting('TWITTER_SITE_USER')
    twitter_pass = get_setting('TWITTER_SITE_PASS')
    if twitter_user and twitter_pass:
        return BasicAuthHandler(twitter_user, twitter_pass)

    # If no basic, check for OAuth
    consumer_token, consumer_secret = get_consumer_creds()
    oauth_token = get_setting('TWITTER_SITE_OAUTHTOKEN')
    oauth_secret = get_setting('TWITTER_SITE_OAUTHSECRET')
    if consumer_token and consumer_secret and oauth_token and oauth_secret:
        auth = OAuthHandler(consumer_token, consumer_secret)
        auth.set_access_token(oauth_token, oauth_secret)
        return auth
github foundit / Piped / doc / tutorials / twitter / 5_markov / twitter_tutorial / provider.py View on Github external
def _get_auth(self, account_name, auth_config):
        """ Returns an auth handler for the given account. """

        if 'username' in auth_config:
            return tweepy.BasicAuthHandler(**auth_config)

        access_token = auth_config.pop('access_token', None)

        auth = tweepy.OAuthHandler(**auth_config)

        if not access_token:
            print 'The account %r is missing the access_key/access_secret.'%account_name
            print 'Go the the following URL to authorize: %s,'%auth.get_authorization_url()
            print 'then paste the PID into this window and press enter.'

            verifier = raw_input('PID: ').strip()
            auth.get_access_token(verifier)

            print 'Add the following keys to the auth configuration %r:'%'twitter.%s.auth'%account_name
            print 'access_token:'
            print '    key: %s' % auth.access_token.key
github hmason / tweetbc / tweetbc.py View on Github external
def init_twitter(self, username, password):
        auth = tweepy.BasicAuthHandler(username, password)
        api = tweepy.API(auth)
        return api
github hmason / tc / load_tweets.py View on Github external
def init_twitter(self, username, password):
        auth = tweepy.BasicAuthHandler(username, password)
        api = tweepy.API(auth)
        return api
github foundit / Piped / doc / tutorials / twitter / 4_processor / twitter_tutorial / provider.py View on Github external
def _get_auth(self, account_name, auth_config):
        """ Returns an auth handler for the given account. """

        if 'username' in auth_config:
            return tweepy.BasicAuthHandler(**auth_config)

        access_token = auth_config.pop('access_token', None)

        auth = tweepy.OAuthHandler(**auth_config)

        if not access_token:
            print 'The account %r is missing the access_key/access_secret.'%account_name
            print 'Go the the following URL to authorize: %s,'%auth.get_authorization_url()
            print 'then paste the PID into this window and press enter.'

            verifier = raw_input('PID: ').strip()
            auth.get_access_token(verifier)

            print 'Add the following keys to the auth configuration %r:'%'twitter.%s.auth'%account_name
            print 'access_token:'
            print '    key: %s' % auth.access_token.key
github ushahidi / Reverberations / twitter_reverb.py View on Github external
def authenticate(usr='0', pswd='0'):
    if usr == '0':
        usr = raw_input("twitter username: ")
        pswd = getpass.getpass("password: ")
    auth = tweepy.BasicAuthHandler(usr, pswd)
    api = tweepy.API(auth)
    return api