Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Authorize `turses` to use a Twitter account.

Return a dictionary with `oauth_token` and `oauth_token_secret` keys
if succesfull, `None` otherwise.

        def get_authorization_tokens():
    """
    Authorize `turses` to use a Twitter account.

    Return a dictionary with `oauth_token` and `oauth_token_secret` keys
    if succesfull, `None` otherwise.
    """
    # This function was borrowed from python-twitter developers and experienced
    # an important refactoring
    #
    # Copyright 2007 The Python-Twitter Developers
    #
    # Licensed under the Apache License, Version 2.0 (the "License");
    # you may not use this file except in compliance with the License.
    # You may obtain a copy of the License at
    #
    #     http://www.apache.org/licenses/LICENSE-2.0
    #
    # Unless required by applicable law or agreed to in writing, software
    # distributed under the License is distributed on an "AS IS" BASIS,
    # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    # See the License for the specific language governing permissions and
    # limitations under the License.
    oauth_consumer = oauth.Consumer(key=TWITTER_CONSUMER_KEY,
                                    secret=TWITTER_CONSUMER_SECRET)
    oauth_client = oauth.Client(oauth_consumer)

    print _('Requesting temporary token from Twitter')

    try:
        oauth_token, oauth_token_secret = get_temporary_tokens(oauth_client)
    except SSLError:
        print _("""There was an SSL certificate error, your user may not have
                   permission to access SSL. Try executing `turses` as a
                   privileged user.""")
        return None
    except Exception as e:
        print e
        return None


    authorization_url = urljoin(BASE_URL, '/oauth/authorize')
    authorization_url_with_token = urljoin(authorization_url,
                                           '?oauth_token=%s' % oauth_token)
    print
    print  _('Please visit the following page to retrieve the pin code needed '
             'to obtain an Authorization Token:')
    print
    print authorization_url_with_token
    print

    pin_code = raw_input(_('Pin code? '))

    print
    print encode(_('Generating and signing request for an access token'))
    print

    # Generate an OAuth token that verifies the identity of the user
    token = oauth.Token(oauth_token, oauth_token_secret)
    token.set_verifier(pin_code)

    # Re-create the OAuth client with the corresponding token
    oauth_client = oauth.Client(oauth_consumer, token)

    try:
        access_tokens = get_access_tokens(oauth_client, pin_code)
        return access_tokens
    except Exception as e:
        print e
        return None
        


src/t/u/turses-0.2.22/turses/config.py   turses(Download)
from turses.utils import encode
from turses.meta import wrap_exceptions
from turses.api.base import get_authorization_tokens
 
# -- Defaults -----------------------------------------------------------------
    def authorize_new_account(self):
        access_tokens = get_authorization_tokens()
        if access_tokens:
            access_token = access_tokens['oauth_token']
            access_token_secret = access_tokens['oauth_token_secret']

src/t/u/turses-HEAD/turses/config.py   turses(Download)
from turses.utils import encode
from turses.meta import wrap_exceptions
from turses.api.base import get_authorization_tokens
 
# -- Defaults -----------------------------------------------------------------
    def authorize_new_account(self):
        access_tokens = get_authorization_tokens()
        if access_tokens:
            access_token = access_tokens['oauth_token']
            access_token_secret = access_tokens['oauth_token_secret']