diff --git a/usos_api/auth.py b/usos_api/auth.py index f47260c..9624f1d 100644 --- a/usos_api/auth.py +++ b/usos_api/auth.py @@ -95,13 +95,19 @@ async def _generate_request_token(self, callback_url: str) -> None: self._oauth_client.resource_owner_secret = self._request_token_secret _LOGGER.info(f"New request token generated: {self._request_token}") - async def get_authorization_url(self, callback_url: str) -> str: + async def get_authorization_url( + self, callback_url: str, confirm_user: bool = False + ) -> str: """ Get the authorization URL. :param callback_url: The callback URL. + :param confirm_user: Whether to confirm the user. + :return: The authorization URL. """ await self._generate_request_token(callback_url) + if confirm_user: + return f"{self.base_address}{self.AUTHORIZE_SUFFIX}?oauth_token={self._request_token}&interactivity=confirm_user" return f"{self.base_address}{self.AUTHORIZE_SUFFIX}?oauth_token={self._request_token}" async def authorize(self, verifier: str, request_token, request_token_secret): diff --git a/usos_api/client.py b/usos_api/client.py index 9006288..7c9a2df 100644 --- a/usos_api/client.py +++ b/usos_api/client.py @@ -111,14 +111,19 @@ async def authorize( verifier, request_token, request_token_secret ) - async def get_authorization_url(self, callback_url: str = "oob"): + async def get_authorization_url( + self, callback_url: str = "oob", confirm_user: bool = False + ) -> str: """ Get the URL to authorize the client. :param callback_url: The URL to redirect to after authorization, leave as "oob" for pin-based authorization. + :param confirm_user: Whether to confirm the user before authorizing the client. :return: The URL to authorize the client. """ - return await self.connection.auth_manager.get_authorization_url(callback_url) + return await self.connection.auth_manager.get_authorization_url( + callback_url, confirm_user + ) def load_access_token(self, access_token: str, access_token_secret: str): """