From 2fdacb75d345821c899bcbed4c5bc5d4d9e568a7 Mon Sep 17 00:00:00 2001 From: derrod Date: Fri, 8 Dec 2023 14:37:42 +0100 Subject: [PATCH] [cli/core/utils] Fix webview login now requiring EGL UA Why are you like this Epic? --- legendary/cli.py | 3 ++- legendary/core.py | 3 +++ legendary/utils/webview_login.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/legendary/cli.py b/legendary/cli.py index 06d6a8f..010a525 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -162,7 +162,8 @@ class LegendaryCLI: else: auth_code = auth_code.strip('"') else: - if do_webview_login(callback_code=self.core.auth_ex_token): + if do_webview_login(callback_code=self.core.auth_ex_token, + user_agent=f'EpicGamesLauncher/{self.core.get_egl_version()}'): logger.info(f'Successfully logged in as "{self.core.lgd.userdata["displayName"]}" via WebView') else: logger.error('WebView login attempt failed, please see log for details.') diff --git a/legendary/core.py b/legendary/core.py index 8acef74..296da30 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -301,6 +301,9 @@ class LegendaryCore: if lgd_config := version_info.get('legendary_config'): self.webview_killswitch = lgd_config.get('webview_killswitch', False) + def get_egl_version(self): + return self._egl_version + def get_update_info(self): return self.lgd.get_cached_version()['data'].get('release_info') diff --git a/legendary/utils/webview_login.py b/legendary/utils/webview_login.py index 1b7e5db..6168842 100644 --- a/legendary/utils/webview_login.py +++ b/legendary/utils/webview_login.py @@ -124,7 +124,7 @@ class MockLauncher: self.window.load_url(logout_url) -def do_webview_login(callback_sid=None, callback_code=None): +def do_webview_login(callback_sid=None, callback_code=None, user_agent=None): api = MockLauncher(callback_sid=callback_sid, callback_code=callback_code) url = login_url @@ -143,7 +143,7 @@ def do_webview_login(callback_sid=None, callback_code=None): window.events.loaded += api.on_loaded try: - webview.start() + webview.start(user_agent=user_agent) except Exception as we: logger.error(f'Running webview failed with {we!r}. If this error persists try the manual ' f'login process by adding --disable-webview to your command line.')