diff --git a/descope/auth.py b/descope/auth.py index 518722627..42a20c5d0 100644 --- a/descope/auth.py +++ b/descope/auth.py @@ -33,7 +33,7 @@ class Auth: def __init__( self, - project_id: str, + project_id: str = None, public_key: str = None, skip_verify: bool = False, ): @@ -188,6 +188,14 @@ def validate_phone(method: DeliveryMethod, phone: str): 400, ERROR_TYPE_INVALID_ARGUMENT, "Invalid delivery method" ) + def refresh_token(self, refresh_token: str) -> dict: + uri = Auth._compose_refresh_token_url() + response = self.do_get(uri, None, None, refresh_token) + + resp = response.json() + auth_info = self._generate_auth_info(resp, refresh_token) + return auth_info + @staticmethod def _validate_and_load_public_key(public_key) -> Tuple[str, jwt.PyJWK, str]: if isinstance(public_key, str): @@ -327,14 +335,6 @@ def _get_default_headers(self, pswd: str = None): headers["Authorization"] = f"Basic {base64.b64encode(bytes).decode('ascii')}" return headers - def refresh_token(self, refresh_token: str) -> dict: - uri = Auth._compose_refresh_token_url() - response = self.do_get(uri, None, None, refresh_token) - - resp = response.json() - auth_info = self._generate_auth_info(resp, refresh_token) - return auth_info - def _validate_and_load_tokens(self, session_token: str, refresh_token: str) -> dict: if not session_token: raise AuthException( diff --git a/descope/descope_client.py b/descope/descope_client.py index 0291925d2..6c2e612ea 100644 --- a/descope/descope_client.py +++ b/descope/descope_client.py @@ -17,7 +17,7 @@ class DescopeClient: def __init__( self, - project_id: str, + project_id: str = None, public_key: str = None, skip_verify: bool = False, ): @@ -106,3 +106,6 @@ def logout(self, refresh_token: str) -> requests.Response: uri = EndpointsV1.logoutPath return self._auth.do_get(uri, None, None, refresh_token) + + def refresh_token(self, refresh_token: str) -> dict: + return self._auth.refresh_token(refresh_token) diff --git a/samples/otp_sample_app.py b/samples/otp_sample_app.py index b9345e705..c82880b36 100644 --- a/samples/otp_sample_app.py +++ b/samples/otp_sample_app.py @@ -46,7 +46,7 @@ def main(): try: logging.info("refreshing the session token..") - claims = descope_client._auth.refresh_token(refresh_token) + claims = descope_client.refresh_token(refresh_token) logging.info( "going to revalidate the session with the newly refreshed token.." )