Ejemplo n.º 1
0
def identify_user():
    """Return the user identity object obtained from the session WDI login."""
    # Get the WDI login object
    wdi_login_obj = get_wdi_login()
    access_token = AccessToken(
        wdi_login_obj.s.auth.client.resource_owner_key,
        wdi_login_obj.s.auth.client.resource_owner_secret
    )
    return identify(OAUTH_MEDIAWIKI_URL, WIKIDP_CONSUMER_TOKEN, access_token)
Ejemplo n.º 2
0
def dologin():
    """Attempt to login."""
    if not ('access_token_key' in session
            and 'access_token_secret' in session):
        raise NameError("No access keys")

    access_token = AccessToken(session['access_token_key'],
                               session['access_token_secret'])
    session['username'] = handshaker.identify(access_token)['username']
    return OAuth1(client_key=consumer_token.key,
                  client_secret=consumer_token.secret,
                  resource_owner_key=access_token.key,
                  resource_owner_secret=access_token.secret)
Ejemplo n.º 3
0
def test_snuggler():
    id = 10
    name = "Herp"
    access_token = AccessToken("nothing", "nonsense")
    snuggler = Snuggler(id, name, access_token)

    eq_(snuggler.id, id)
    eq_(snuggler.name, name)
    eq_(snuggler.access_token, access_token)

    # This should not match because the cookies member becomes None when the
    # object is serialized.
    #neq_(snuggler, Snuggler.deserialize(snuggler.serialize()))

    # Check that we're equal with a Snuggler that has no cookies.
    eq_(Snuggler(id, name), Snuggler.deserialize(snuggler.serialize()))
Ejemplo n.º 4
0
 def get_access_token(self):
     if self.wikidata_access_token is None:
         return None
     return AccessToken(self.wikidata_access_token['key'].encode(),
                        self.wikidata_access_token['secret'].encode())