diff --git a/openeo/rest/auth/oidc.py b/openeo/rest/auth/oidc.py index 2e4f3f50c..f4a91ce92 100644 --- a/openeo/rest/auth/oidc.py +++ b/openeo/rest/auth/oidc.py @@ -669,9 +669,9 @@ def __init__( self, client_info: OidcClientInfo, display: Callable[[str], None] = print, - device_code_url: str = None, - max_poll_time=5 * 60, - use_pkce: Union[bool, None] = None, + device_code_url: Optional[str] = None, + max_poll_time: float = 5 * 60, + use_pkce: Optional[bool] = None, requests_session: Optional[requests.Session] = None, ): super().__init__(client_info=client_info, requests_session=requests_session) diff --git a/openeo/rest/connection.py b/openeo/rest/connection.py index 7fc9cfccc..6ef25f3f9 100644 --- a/openeo/rest/connection.py +++ b/openeo/rest/connection.py @@ -532,11 +532,13 @@ def authenticate_oidc_device( return self._authenticate_oidc(authenticator, provider_id=provider_id, store_refresh_token=store_refresh_token) def authenticate_oidc( - self, - provider_id: str = None, - client_id: Union[str, None] = None, client_secret: Union[str, None] = None, - store_refresh_token: bool = True, - use_pkce: Union[bool, None] = None, + self, + provider_id: Optional[str] = None, + client_id: Optional[str] = None, + client_secret: Optional[str] = None, + store_refresh_token: bool = True, + use_pkce: Optional[bool] = None, + display: Callable[[str], None] = print, ): """ Do OpenID Connect authentication, first trying refresh tokens and falling back on device code flow. @@ -575,8 +577,14 @@ def authenticate_oidc( # Fall back on device code flow # TODO: make it possible to do other fallback flows too? _log.info("Trying device code flow.") - authenticator = OidcDeviceAuthenticator(client_info=client_info, use_pkce=use_pkce) - con = self._authenticate_oidc(authenticator, provider_id=provider_id, store_refresh_token=store_refresh_token) + authenticator = OidcDeviceAuthenticator( + client_info=client_info, use_pkce=use_pkce, display=display + ) + con = self._authenticate_oidc( + authenticator, + provider_id=provider_id, + store_refresh_token=store_refresh_token, + ) print("Authenticated using device code flow.") return con