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 06d6a8fc..010a525e 100644 --- a/legendary/cli.py +++ b/legendary/cli.py @@ -162,7 +162,8 @@ def auth(self, args): 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 8acef74a..296da30e 100644 --- a/legendary/core.py +++ b/legendary/core.py @@ -301,6 +301,9 @@ def apply_lgd_config(self, version_info=None): 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 1b7e5dba..6168842c 100644 --- a/legendary/utils/webview_login.py +++ b/legendary/utils/webview_login.py @@ -124,7 +124,7 @@ def login_sid(self, sid_json): 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.')