Esempio n. 1
0
    def verify(self, req):
        """
        Verifies returned user and extracts user information
        @param req: the GET data from the page call.
        @return: The users information
        @rtype: dict
        """
        from lib.urlparse import parse_qsl
        from django.utils import simplejson as json
        auth_token = req["oauth_token"]
        auth_verifier = req["oauth_verifier"]
        dataset = OAuthTW.get_by_key_name(auth_token)
        token = Token(auth_token, dataset.secret)
        token.set_verifier(auth_verifier)
        self.client = Client(self.consumer, token)
        resp, content = self.client.request(self.access_token_url, "POST") #@UnusedVariable
        auth = dict(parse_qsl(content))

        token = Token(auth['oauth_token'], auth['oauth_token_secret'])
        self.client = Client(self.consumer, token)
        resp, content = self.client.request(self.userinfo_url, "GET") #@UnusedVariable
        info = json.loads(content)
        info.update(auth)
        dataset.delete()
        return info