Heroic-Games-Launcher / HeroicGamesLauncher

A games launcher for GOG, Amazon and Epic Games for Linux, Windows and macOS.
https://heroicgameslauncher.com
GNU General Public License v3.0
8.25k stars 433 forks source link

Epic Games External Login - Improve handling if full JSON is passed instead of SID #1661

Closed StefanLobbenmeier closed 2 years ago

StefanLobbenmeier commented 2 years ago

Describe the bug

(Log in via the embedded browser works without issues. I logged out to reproduce the bug. But this time I can always reproduce)

When I use External Login to authenticate, it opens my browser, and there I can copy the JSON and paste it to Heroic. It then returns me back to the Manage Accounts Screen without having the account: image

Legendary will also complain about missing credentials when I try list-games:

C:\Users\Stefan>C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary list-games
[cli] INFO: Logging in...
Traceback (most recent call last):
  File "legendary\cli.py", line 3053, in <module>
  File "legendary\cli.py", line 2964, in main
  File "legendary\cli.py", line 190, in list_games
  File "legendary\core.py", line 178, in login
ValueError: No saved credentials

Strangely I can use legendary auth to complete authentication without issues:

C:\Users\Stefan>C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary auth
[cli] INFO: Testing existing login data if present...
Please login via the epic web login!
If the web page did not open automatically, please manually open the following URL: https://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect
Please enter the "sid" value from the JSON response: {"redirectUrl":"https://epicgames.com/account/personal","authorizationCode":null,"sid":"asdfsdfasdfasdfasdf"}
[cli] INFO: Successfully logged in as "asdfasdfasdfsdf"

Add logs

(23:30:34) DEBUG: [Legendary]: Running Legendary command: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary --version

(23:30:38) INFO: [Legendary]: Legendary location: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary

(23:30:38) INFO: [Gog]: GOGDL location: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\gogdl

(23:30:38) INFO: [Backend]:

Heroic Version: 2.3.10 Brook

Legendary Version: 0.20.27 Dark Energy (hotfix)

OS: Microsoft Windows 10 Education KERNEL: 10.0.19044 ARCH: x64

CPU: Intel Core™ i5-8600K @3.6

RAM: Total: 15.88 GiB Available: 10.3 GiB

GRAPHICS: GPU0: Intel(R) UHD Graphics 630 VRAM: 1024MB DRIVER: GPU1: NVIDIA GeForce RTX 3070 VRAM: 8192MB DRIVER: 516.59

(23:30:38) INFO: [Gog]: Getting data about the user

(23:30:38) WARNING: [Backend]: Protocol already registered.

(23:30:38) INFO: [Gog]: Saved user data to config

(23:30:39) INFO: [Frontend]: Refreshing Library

(23:30:39) INFO: [Legendary]: Refreshing library...

(23:30:39) INFO: [Legendary]: Refreshing Epic Games...

(23:30:39) INFO: [Gog]: Getting GOG library

(23:30:39) INFO: [Gog]: Number of library pages: 1

(23:30:39) INFO: [Gog]: Saved games data

(23:30:39) DEBUG: [Legendary]: Running Legendary command: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary list

(23:30:41) INFO: [Legendary]: Updating game list

(23:30:41) INFO: [Legendary]: Game List Updated

(23:30:41) INFO: [Frontend]: No cache found, getting data from legendary...

(23:30:41) INFO: [Legendary]: Refreshing library...

(23:30:41) INFO: [Legendary]: Updating game list

(23:30:41) INFO: [Legendary]: Game List Updated

(23:30:41) INFO: [Legendary]: Checking for game updates: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary list-installed --check-updates --tsv

(23:30:41) DEBUG: [Legendary]: Running Legendary command: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary list-installed --check-updates --tsv

(23:30:42) INFO: [Legendary]: Logging out: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary auth --delete

(23:30:42) DEBUG: [Legendary]: Running Legendary command: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary auth --delete

(23:30:43) DEBUG: [Legendary]: Running Legendary command: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary cleanup

(23:30:43) INFO: [Frontend]: Refreshing Library

(23:30:43) INFO: [Legendary]: Refreshing library...

(23:30:43) INFO: [Gog]: Getting GOG library

(23:30:43) INFO: [Legendary]: Found 0 game(s) to update

(23:30:43) INFO: [Gog]: Found 0 game(s) to update

(23:30:43) INFO: [Gog]: Number of library pages: 1

(23:30:46) WARNING: [Gog]: Unable to get covers from gamesdb for Spring Sale Goodies Collection #1. Trying to get it from api.gog.com

(23:30:46) WARNING: [Gog]: Couldn't get info from api.gog.com, Using fallback vertical image

(23:30:46) WARNING: [Gog]: Unable to get covers from gamesdb for The Witcher Goodies Collection. Trying to get it from api.gog.com

(23:30:46) WARNING: [Gog]: Couldn't get info from api.gog.com, Using fallback vertical image

(23:30:47) WARNING: [Gog]: Unable to get covers from gamesdb for Wanderlust: Transsiberian. Trying to get it from api.gog.com

(23:30:47) INFO: [Gog]: Saved games data

(23:30:47) INFO: [Frontend]: No cache found, getting data from legendary...

(23:30:47) INFO: [Legendary]: Refreshing library...

(23:30:47) INFO: [Gog]: Found 0 game(s) to update

(23:30:59) INFO: [Legendary]: Logging in with Legendary: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary auth --sid

(23:30:59) DEBUG: [Legendary]: Running Legendary command: C:\Users\Stefan\AppData\Local\Programs\heroic\resources\app.asar.unpacked\build\bin\win32\legendary auth --sid

(23:31:01) INFO: [Frontend]: Refreshing Library

(23:31:01) INFO: [Legendary]: Refreshing library...

(23:31:01) INFO: [Frontend]: Called Login

(23:31:01) INFO: [Frontend]: No cache found, getting data from legendary...

(23:31:01) INFO: [Legendary]: Refreshing library...

Steps to reproduce

  1. In Heroic, Click on Manage Accounts
  2. Logout Epic Games
  3. Click External Login
  4. Click on "Epic Store here"
  5. (authenticate in browser, but in my case this was skipped because I was already authenticated in the browser)
  6. Copy the SID
  7. Click LOG IN

Expected behavior

I am logged in

Screenshots

No response

System Information

Additional information

No response

StefanLobbenmeier commented 2 years ago

I noticed that in external login, epic.login is called with the whole JSON string: https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/43c1eaa0d34b5988514430d64da1d64474d8176d/src/screens/Login/components/SIDLogin/index.tsx#L27

But in Embedded Browser Login epic.login is called with a the sid field from the parsed JSON : https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/6c3c7ce941e182c2cd1ea8581da4c0c4147b7d19/src/screens/WebView/index.tsx#L109

So I think this is an easy fix, external login also needs to parse the JSON and read the sid field instead of providing legendary the whole json. Should also be reproducible on any platform 😄

flavioislima commented 2 years ago

No, this is working fine. We are destructuring the sid string from the json so it is a string. I wonder if the issue is because you are using a Windows 10 educational.

What might he happening is that the frontend is not updating the login status, did you restart heroic?

StefanLobbenmeier commented 2 years ago

Yeah I dont think it is a frontend issue. After restarting heroic I am still logged out, and I also verified with the legendary command in the terminal that legendary is still signed off.

No, this is working fine. We are destructuring the sid string from the json so it is a string.

Please double check, I cannot see any destructuring in the external login flow: https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/43c1eaa0d34b5988514430d64da1d64474d8176d/src/screens/Login/components/SIDLogin/index.tsx#L27

Nocccer commented 2 years ago

I can see that you passing the whole JSON object to legendary. If you do this in heroic it will break. If you can read, we only want the sid value which is a string! Please confirm that this bug also happens only with the sid value.

Even legendary asks for the sid value only. Wonder why it is succesfully and thinks your sid is your username?

StefanLobbenmeier commented 2 years ago

Ahh you’re absolutely right, it does ask for the Sid number: https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/blob/1522b3b01aa2ee2e818df19ccc841bbce6c8b4af/public/locales/en/login.json#L10

i Wonder if we can still improve the ux. legendary auth. accepts both the Sid or the full json, is that something we can also consider?

in any case it would be nice if there was an error message instead of the screen closing.

flavioislima commented 2 years ago

I will close this one, we won't change that and the instructions on legendary clearly say to pass only the SID number. If it works with JSON, nice, but we won't change this now.

Nocccer commented 2 years ago

We should still consider showing a error in frontend, if login fails.

flavioislima commented 2 years ago

We should still consider showing a error in frontend, if login fails.

We used to have that. It showed a dialog or a error at the bottom if I'm not mistaken. But after changing the layout probably this stopped working.