Run OAuth 2.0 code exchange (out-of-band flow.) Runs the OAuth 2.0 Authorization Code exchange flow using the out-of-band code exchange. After authorizing access by visiting the authorization URL displayed, user has to copy the authorization code and paste
(self, *, open_browser: Union[bool, abc.Callable] = False)
| 405 | return False |
| 406 | |
| 407 | def run_oob_flow(self, *, open_browser: Union[bool, abc.Callable] = False): |
| 408 | """Run OAuth 2.0 code exchange (out-of-band flow.) |
| 409 | |
| 410 | Runs the OAuth 2.0 Authorization Code exchange flow using the out-of-band code |
| 411 | exchange. |
| 412 | |
| 413 | After authorizing access by visiting the authorization URL displayed, |
| 414 | user has to copy the authorization code and paste it back in their |
| 415 | terminal. On successful completion Leap API access and refresh tokens |
| 416 | are returned. |
| 417 | """ |
| 418 | self.redirect_uri = self._OOB_REDIRECT_URI |
| 419 | |
| 420 | url = self.get_authorization_url() |
| 421 | click.echo(click.style(self._VISIT_AUTH_MSG, bold=True), nl=False) |
| 422 | click.echo(click.style(url, underline=True)) |
| 423 | click.echo() |
| 424 | if open_browser: |
| 425 | if callable(open_browser): |
| 426 | open_browser(url) |
| 427 | else: |
| 428 | webbrowser.open(url) |
| 429 | |
| 430 | code = click.prompt(click.style(self._INPUT_CODE_MSG, bold=True)) |
| 431 | click.echo() |
| 432 | return self.fetch_token(code=code) |
| 433 | |
| 434 | def run_redirect_flow(self, *, open_browser: Union[bool, abc.Callable] = False, |
| 435 | timeout: Optional[float] = None): |