MCPcopy
hub / github.com/tornadoweb/tornado / facebook_request

Method facebook_request

tornado/auth.py:1095–1152  ·  view source on GitHub ↗

Fetches the given relative API path, e.g., "/btaylor/picture" If the request is a POST, ``post_args`` should be provided. Query string arguments should be given as keyword arguments. An introduction to the Facebook Graph API can be found at http://developers.faceboo

(
        self,
        path: str,
        access_token: Optional[str] = None,
        post_args: Optional[Dict[str, Any]] = None,
        **args: Any,
    )

Source from the content-addressed store, hash-verified

1093 return fieldmap
1094
1095 async def facebook_request(
1096 self,
1097 path: str,
1098 access_token: Optional[str] = None,
1099 post_args: Optional[Dict[str, Any]] = None,
1100 **args: Any,
1101 ) -> Any:
1102 """Fetches the given relative API path, e.g., "/btaylor/picture"
1103
1104 If the request is a POST, ``post_args`` should be provided. Query
1105 string arguments should be given as keyword arguments.
1106
1107 An introduction to the Facebook Graph API can be found at
1108 http://developers.facebook.com/docs/api
1109
1110 Many methods require an OAuth access token which you can
1111 obtain through `~OAuth2Mixin.authorize_redirect` and
1112 `get_authenticated_user`. The user returned through that
1113 process includes an ``access_token`` attribute that can be
1114 used to make authenticated requests via this method.
1115
1116 Example usage:
1117
1118 .. testcode::
1119
1120 class MainHandler(tornado.web.RequestHandler,
1121 tornado.auth.FacebookGraphMixin):
1122 @tornado.web.authenticated
1123 async def get(self):
1124 new_entry = await self.facebook_request(
1125 "/me/feed",
1126 post_args={"message": "I am posting from my Tornado application!"},
1127 access_token=self.current_user["access_token"])
1128
1129 if not new_entry:
1130 # Call failed; perhaps missing permission?
1131 self.authorize_redirect()
1132 return
1133 self.finish("Posted a message!")
1134
1135 The given path is relative to ``self._FACEBOOK_BASE_URL``,
1136 by default "https://graph.facebook.com".
1137
1138 This method is a wrapper around `OAuth2Mixin.oauth2_request`;
1139 the only difference is that this method takes a relative path,
1140 while ``oauth2_request`` takes a complete url.
1141
1142 .. versionchanged:: 3.1
1143 Added the ability to override ``self._FACEBOOK_BASE_URL``.
1144
1145 .. versionchanged:: 6.0
1146
1147 The ``callback`` argument was removed. Use the returned awaitable object instead.
1148 """
1149 url = self._FACEBOOK_BASE_URL + path
1150 return await self.oauth2_request(
1151 url, access_token=access_token, post_args=post_args, **args
1152 )

Callers 2

getMethod · 0.80

Calls 1

oauth2_requestMethod · 0.80

Tested by

no test coverage detected