Skip to content
This repository was archived by the owner on Jun 4, 2019. It is now read-only.
This repository was archived by the owner on Jun 4, 2019. It is now read-only.

Option to use stored tokens #15

@x1ddos

Description

@x1ddos

Reported by muijsenbergq


Hi,

I'm using your library and i need to be able to use stored tokens and try to reuse them. As a separate path from the OAuth flow.

At the moment a hacked away a little bit to achieve this functionality but maybe it's an idea to implement this (the right way)?

This i my method to use existing tokens and tap into your library.
I made "get_consumer_info_for()" a class method,made it always return a 3-tuple and for the rest using the implementation from your demo.

def try_oauth(tokens):
    provider = tokens.provider
    client_id, client_secret, scope = AuthHandler.get_consumer_info_for(provider)
    fetcher = getattr(AuthHandler(), '_get_%s_user_info' % provider)
    auth_info = {'oauth_token': tokens.oauth_token, 'oauth_token_secret': tokens.oauth_secret}
    user_data = fetcher(auth_info, key=client_id, secret=client_secret)
    if user_data:
        auth_id = get_auth_id(user_data, provider)
        ....

btw, using this class to store tokens in db

class UserTokens(db.Model):
    created = db.IntegerProperty(required=True)
    provider = db.StringProperty(indexed=False, required=True)
    cookie = db.StringProperty()
    oauth_token = db.StringProperty(indexed=False, required=True)
    oauth_secret = db.StringProperty(indexed=False, required=True)
    user = ....

Thanks!

Moved here from https://code.google.com/p/gae-simpleauth/issues/detail?id=6

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions