Python rauth.OAuth1Service() Examples

The following are 4 code examples of rauth.OAuth1Service(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module rauth , or try the search function .
Example #1
Source File: oauth.py    From django-htk with MIT License 6 votes vote down vote up
def __init__(self, app_key, app_secret, user_social_auth):
        """Constructor for YahooOAuthClient

        `app_key` - Yahoo App Key
        `app_secret` - Yahoo App Secret
        `user_social_auth` - UserSocialAuth model to store refreshed token
        """
        # UserSocialAuth needed to access the access token
        self.last_error = None
        self.user_social_auth = user_social_auth
        self.access_token = user_social_auth.extra_data.get('access_token')
        self.oauth = OAuth1Service(
                name='Yahoo',
                consumer_key=app_key,
                consumer_secret=app_secret,
                request_token_url=YAHOO_OAUTH_REQUEST_TOKEN_URL,
                access_token_url=YAHOO_OAUTH_ACCESS_TOKEN_URL,
                authorize_url=YAHOO_OAUTH_AUTHORIZE_URL,
            )
        self.session = self.oauth.get_session((self.access_token['oauth_token'], self.access_token['oauth_token_secret'])) 
Example #2
Source File: osm_access.py    From upload-scripts with MIT License 5 votes vote down vote up
def __osm_auth_service() -> OAuth1Service:
    """Factory method that builds osm auth service"""
    osm = OAuth1Service(
        name='openstreetmap',
        consumer_key='rBWV8Eaottv44tXfdLofdNvVemHOL62Lsutpb9tw',
        consumer_secret='rpmeZIp49sEjjcz91X9dsY0vD1PpEduixuPy8T6S',
        request_token_url='https://www.openstreetmap.org/oauth/request_token',
        access_token_url='https://www.openstreetmap.org/oauth/access_token',
        authorize_url='https://www.openstreetmap.org/oauth/authorize',
        signature_obj='',
        base_url='https://www.openstreetmap.org/')
    return osm 
Example #3
Source File: oauth.py    From flask-oauth-example with MIT License 5 votes vote down vote up
def __init__(self):
        super(TwitterSignIn, self).__init__('twitter')
        self.service = OAuth1Service(
            name='twitter',
            consumer_key=self.consumer_id,
            consumer_secret=self.consumer_secret,
            request_token_url='https://api.twitter.com/oauth/request_token',
            authorize_url='https://api.twitter.com/oauth/authorize',
            access_token_url='https://api.twitter.com/oauth/access_token',
            base_url='https://api.twitter.com/1.1/'
        ) 
Example #4
Source File: backend.py    From zotero-cli with MIT License 5 votes vote down vote up
def create_api_key():
        """ Interactively create a new API key via Zotero's OAuth API.

        Requires the user to enter a verification key displayed in the browser.

        :returns:   API key and the user's library ID
        """
        auth = OAuth1Service(
            name='zotero',
            consumer_key=CLIENT_KEY,
            consumer_secret=CLIENT_SECRET,
            request_token_url=REQUEST_TOKEN_URL,
            access_token_url=ACCESS_TOKEN_URL,
            authorize_url=AUTH_URL,
            base_url=BASE_URL)
        token, secret = auth.get_request_token(
            params={'oauth_callback': 'oob'})
        auth_url = auth.get_authorize_url(token)
        auth_url += '&' + urlencode({
            'name': 'zotero-cli',
            'library_access': 1,
            'notes_access': 1,
            'write_access': 1,
            'all_groups': 'read'})
        click.echo("Opening {} in browser, please confirm.".format(auth_url))
        click.launch(auth_url)
        verification = click.prompt("Enter verification code")
        token_resp = auth.get_raw_access_token(
            token, secret, method='POST',
            data={'oauth_verifier': verification})
        if not token_resp:
            logging.debug(token_resp.content)
            click.fail("Error during API key generation.")
        access = urlparse.parse_qs(token_resp.text)
        return access['oauth_token'][0], access['userID'][0]