MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / run_oob_flow

Method run_oob_flow

dwave/cloud/auth/flows.py:407–432  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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):

Callers 2

_loginFunction · 0.80
test_oobMethod · 0.80

Calls 2

get_authorization_urlMethod · 0.80
fetch_tokenMethod · 0.80

Tested by 1

test_oobMethod · 0.64