From 94a561cea9c74255b5780b3a343594e9a8a3d2a6 Mon Sep 17 00:00:00 2001 From: "Fabio M. Graetz, Ph.D" Date: Thu, 9 Nov 2023 22:38:08 +0100 Subject: [PATCH] Feat: If PKCE AuthorizationClient cannot open browser, ask user to do so manually (#1947) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * If PKCE AuthorizationClient cannot open browser, ask user to do so manually Signed-off-by: Fabio Grätz * Remove new line Signed-off-by: Fabio Grätz --------- Signed-off-by: Fabio Grätz Co-authored-by: Fabio Grätz --- flytekit/clients/auth/auth_client.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flytekit/clients/auth/auth_client.py b/flytekit/clients/auth/auth_client.py index bab4a011dc..8001bf8885 100644 --- a/flytekit/clients/auth/auth_client.py +++ b/flytekit/clients/auth/auth_client.py @@ -15,6 +15,7 @@ from multiprocessing import get_context from urllib.parse import urlencode as _urlencode +import click import requests as _requests from .default_html import get_default_success_html @@ -281,7 +282,10 @@ def _request_authorization_code(self): query = _urlencode(self._request_auth_code_params) endpoint = _urlparse.urlunparse((scheme, netloc, path, None, query, None)) logging.debug(f"Requesting authorization code through {endpoint}") - _webbrowser.open_new_tab(endpoint) + + success = _webbrowser.open_new_tab(endpoint) + if not success: + click.secho(f"Please open the following link in your browser to authenticate: {endpoint}") def _credentials_from_response(self, auth_token_resp) -> Credentials: """