From cbdc3d8190c378b09a6c3742a89e4246f688db8a Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Fri, 14 Apr 2023 14:36:24 +0200 Subject: [PATCH] adjust auth helper a small bit --- music_assistant/server/helpers/auth.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/music_assistant/server/helpers/auth.py b/music_assistant/server/helpers/auth.py index 46054370..197b136b 100644 --- a/music_assistant/server/helpers/auth.py +++ b/music_assistant/server/helpers/auth.py @@ -45,8 +45,16 @@ class AuthenticationHelper: async def authenticate(self, auth_url: str, timeout: int = 60) -> dict[str, str]: """Start the auth process and return any query params if received on the callback.""" + self.send_url(auth_url) + return await self.wait_for_callback(timeout) + + def send_url(self, auth_url: str) -> None: + """Send the user to the given URL to authenticate (or fill in a code).""" # redirect the user in the frontend to the auth url self.mass.signal_event(EventType.AUTH_SESSION, self.session_id, auth_url) + + async def wait_for_callback(self, timeout: int = 60) -> dict[str, str]: + """Wait for the external party to call the callback and return any query strings.""" async with asyncio.timeout(timeout): return await self._callback_response.get() -- 2.34.1