Skip to content

Commit

Permalink
Add confirm_user parameter to get_authorization_url
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoni-Czaplicki committed Jul 7, 2024
1 parent 9fb5049 commit b0d8c7f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 7 additions & 1 deletion usos_api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 7 additions & 2 deletions usos_api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down

0 comments on commit b0d8c7f

Please sign in to comment.