Skip to content

Commit

Permalink
[cli/core/utils] Fix webview login now requiring EGL UA
Browse files Browse the repository at this point in the history
Why are you like this Epic?
  • Loading branch information
derrod committed Dec 8, 2023
1 parent d2963db commit 2fdacb7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion legendary/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand Down
3 changes: 3 additions & 0 deletions legendary/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
4 changes: 2 additions & 2 deletions legendary/utils/webview_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.')
Expand Down

0 comments on commit 2fdacb7

Please sign in to comment.