Demo entry 4175140

test it for use


Submitted by anonymous on Mar 25, 2016 at 11:41
Language: Python. Code size: 3.2 kB.

    def get_authenticated_user(self, callback, http_client=None):
        """Fetches the authenticated user data upon redirect.

        This method should be called by the handler that receives the
        redirect from the `authenticate_redirect()` method (which is
        often the same as the one that calls it; in that case you would
        call `get_authenticated_user` if the ``openid.mode`` parameter
        is present and `authenticate_redirect` if it is not).

        The result of this method will generally be used to set a cookie.
        # Verify the OpenID response via direct request to the OP
        args = dict((k, v[-1]) for k, v in self.request.arguments.items())
        args["openid.mode"] = u"check_authentication"
        url = self._OPENID_ENDPOINT
        if http_client is None:
            http_client = self.get_auth_http_client()
        http_client.fetch(url, functools.partial(
            self._on_authentication_verified, callback),
            method="POST", body=urllib_parse.urlencode(args))

    def _openid_args(self, callback_uri, ax_attrs=[], oauth_scope=None):
        url = urlparse.urljoin(self.request.full_url(), callback_uri)
        args = {
            "openid.ns": "",
            "openid.return_to": url,
            "openid.realm": urlparse.urljoin(url, '/'),
            "openid.mode": "checkid_setup",
        if ax_attrs:
                "": "",
                "": "fetch_request",
            ax_attrs = set(ax_attrs)
            required = []
            if "name" in ax_attrs:
                ax_attrs -= set(["name", "firstname", "fullname", "lastname"])
                required += ["firstname", "fullname", "lastname"]
            known_attrs = {
                "email": "",
                "language": "",
                "username": "",
            for name in ax_attrs:
                args["" + name] = known_attrs[name]
            args[""] = ",".join(required)
        if oauth_scope:
                "openid.oauth.scope": oauth_scope,
        return args

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).