Redirects the user to obtain OAuth authorization for this service. The ``callback_uri`` may be omitted if you have previously registered a callback URI with the third-party service. For some services, you must use a previously-registered callback URI and cannot speci
(
self,
callback_uri: Optional[str] = None,
extra_params: Optional[Dict[str, Any]] = None,
http_client: Optional[httpclient.AsyncHTTPClient] = None,
)
| 288 | """ |
| 289 | |
| 290 | async def authorize_redirect( |
| 291 | self, |
| 292 | callback_uri: Optional[str] = None, |
| 293 | extra_params: Optional[Dict[str, Any]] = None, |
| 294 | http_client: Optional[httpclient.AsyncHTTPClient] = None, |
| 295 | ) -> None: |
| 296 | """Redirects the user to obtain OAuth authorization for this service. |
| 297 | |
| 298 | The ``callback_uri`` may be omitted if you have previously |
| 299 | registered a callback URI with the third-party service. For |
| 300 | some services, you must use a previously-registered callback |
| 301 | URI and cannot specify a callback via this method. |
| 302 | |
| 303 | This method sets a cookie called ``_oauth_request_token`` which is |
| 304 | subsequently used (and cleared) in `get_authenticated_user` for |
| 305 | security purposes. |
| 306 | |
| 307 | This method is asynchronous and must be called with ``await`` |
| 308 | or ``yield`` (This is different from other ``auth*_redirect`` |
| 309 | methods defined in this module). It calls |
| 310 | `.RequestHandler.finish` for you so you should not write any |
| 311 | other response after it returns. |
| 312 | |
| 313 | .. versionchanged:: 3.1 |
| 314 | Now returns a `.Future` and takes an optional callback, for |
| 315 | compatibility with `.gen.coroutine`. |
| 316 | |
| 317 | .. versionchanged:: 6.0 |
| 318 | |
| 319 | The ``callback`` argument was removed. Use the returned |
| 320 | awaitable object instead. |
| 321 | |
| 322 | """ |
| 323 | if callback_uri and getattr(self, "_OAUTH_NO_CALLBACKS", False): |
| 324 | raise Exception("This service does not support oauth_callback") |
| 325 | if http_client is None: |
| 326 | http_client = self.get_auth_http_client() |
| 327 | assert http_client is not None |
| 328 | if getattr(self, "_OAUTH_VERSION", "1.0a") == "1.0a": |
| 329 | response = await http_client.fetch( |
| 330 | self._oauth_request_token_url( |
| 331 | callback_uri=callback_uri, extra_params=extra_params |
| 332 | ) |
| 333 | ) |
| 334 | else: |
| 335 | response = await http_client.fetch(self._oauth_request_token_url()) |
| 336 | url = self._OAUTH_AUTHORIZE_URL # type: ignore |
| 337 | self._on_request_token(url, callback_uri, response) |
| 338 | |
| 339 | async def get_authenticated_user( |
| 340 | self, http_client: Optional[httpclient.AsyncHTTPClient] = None |