MCPcopy Create free account
hub / github.com/EasyIME/PIME / get_authenticated_user

Method get_authenticated_user

python/python3/tornado/auth.py:931–1036  ·  view source on GitHub ↗

Handles the login for the Facebook user, returning a user object. Example usage: .. testcode:: class FacebookGraphLoginHandler(tornado.web.RequestHandler, tornado.auth.FacebookGraphMixin): async def get(self):

(
        self,
        redirect_uri: str,
        client_id: str,
        client_secret: str,
        code: str,
        extra_fields: Optional[Dict[str, Any]] = None,
    )

Source from the content-addressed store, hash-verified

929 _FACEBOOK_BASE_URL = "https://graph.facebook.com"
930
931 async def get_authenticated_user(
932 self,
933 redirect_uri: str,
934 client_id: str,
935 client_secret: str,
936 code: str,
937 extra_fields: Optional[Dict[str, Any]] = None,
938 ) -> Optional[Dict[str, Any]]:
939 """Handles the login for the Facebook user, returning a user object.
940
941 Example usage:
942
943 .. testcode::
944
945 class FacebookGraphLoginHandler(tornado.web.RequestHandler,
946 tornado.auth.FacebookGraphMixin):
947 async def get(self):
948 if self.get_argument("code", False):
949 user = await self.get_authenticated_user(
950 redirect_uri='/auth/facebookgraph/',
951 client_id=self.settings["facebook_api_key"],
952 client_secret=self.settings["facebook_secret"],
953 code=self.get_argument("code"))
954 # Save the user with e.g. set_secure_cookie
955 else:
956 self.authorize_redirect(
957 redirect_uri='/auth/facebookgraph/',
958 client_id=self.settings["facebook_api_key"],
959 extra_params={"scope": "read_stream,offline_access"})
960
961 .. testoutput::
962 :hide:
963
964 This method returns a dictionary which may contain the following fields:
965
966 * ``access_token``, a string which may be passed to `facebook_request`
967 * ``session_expires``, an integer encoded as a string representing
968 the time until the access token expires in seconds. This field should
969 be used like ``int(user['session_expires'])``; in a future version of
970 Tornado it will change from a string to an integer.
971 * ``id``, ``name``, ``first_name``, ``last_name``, ``locale``, ``picture``,
972 ``link``, plus any fields named in the ``extra_fields`` argument. These
973 fields are copied from the Facebook graph API
974 `user object <https://developers.facebook.com/docs/graph-api/reference/user>`_
975
976 .. versionchanged:: 4.5
977 The ``session_expires`` field was updated to support changes made to the
978 Facebook API in March 2017.
979
980 .. versionchanged:: 6.0
981
982 The ``callback`` argument was removed. Use the returned awaitable object instead.
983 """
984 http = self.get_auth_http_client()
985 args = {
986 "redirect_uri": redirect_uri,
987 "code": code,
988 "client_id": client_id,

Callers

nothing calls this directly

Calls 7

facebook_requestMethod · 0.95
joinMethod · 0.80
get_auth_http_clientMethod · 0.45
updateMethod · 0.45
fetchMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected