Repository: lutris/lutris

Issue:
Can't use Epic Games Store as source
Lutris no longer lists games from the Epic Games Store.
In fact, after disconnecting, further attempts to reconnect to an Epic Games account from Lutris don't seem to do anything: after logging in, the authentication window closes and nothing else happens.

Seen on:
- Lutris version: 0.5.10.1
- OS,DE: Pop!_OS 22.04, Gnome 42.3.1

Edit: [Somebody else has also reported this issue on the forums](https://forums.lutris.net/t/cant-connect-epic-games-as-source/16118).
Can't use Epic Games Store as source
Lutris no longer lists games from the Epic Games Store.
In fact, after disconnecting, further attempts to reconnect to an Epic Games account from Lutris don't seem to do anything: after logging in, the authentication window closes and nothing else happens.

Seen on:
- Lutris version: 0.5.10.1
- OS,DE: Pop!_OS 22.04, Gnome 42.3.1

Edit: [Somebody else has also reported this issue on the forums](https://forums.lutris.net/t/cant-connect-epic-games-as-source/16118).


Discussion:
Having the same symptoms. I've tried starting lutris from the CLI to get some logs and here's what I've got:

```
$ lutris 
2022-09-02 08:55:44,068: Command /usr/sbin/lspci after 3 seconds
Gtk-Message: 08:55:44.652: Failed to load module "appmenu-gtk-module"
2022-09-02 08:55:44,654: Starting Lutris 0.5.10.1
2022-09-02 08:55:44,692: No folder at /home/XXX/.local/share/lutris/runners/retroarch/
2022-09-02 08:55:45,669: Running Intel Mesa driver 21.1.8 on Mesa Intel(R) HD Graphics 530 (SKL GT2) (0x191b)
2022-09-02 08:55:45,670: GPU: 8086:191B 1028:06E0 (i915 drivers)
2022-09-02 08:55:45,671: GPU: 1002:682B 1028:06E0 (radeon drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

2022-09-02 08:55:45,788: Startup complete

(lutris:358982): GLib-GIO-CRITICAL **: 08:55:46.061: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
2022-09-02 08:55:51,833: EGS Token expired
2022-09-02 08:55:51,842: Error while completing task <bound method BaseService.reload of <egs.EpicGamesStoreService object at 0x7fdedddceb40 (lutris+services+egs+EpicGamesStoreService at 0x558a74343e40)>>: <class 'lutris.services.base.AuthTokenExpired'> 
  File "/usr/lib/python3.9/site-packages/lutris/util/jobs.py", line 34, in target
    result = self.function(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/lutris/services/base.py", line 96, in reload
    self.load()
  File "/usr/lib/python3.9/site-packages/lutris/services/egs.py", line 323, in load
    raise AuthTokenExpired from ex
Gtk-Message: 08:55:52.142: Failed to load module "appmenu-gtk-module"
https://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect:1:164: CONSOLE RENDERING ERROR Viewport argument key "minimal-ui" not recognized and ignored.
https://www.epicgames.com/id/api/redirect:1:1: CONSOLE SECURITY ERROR Refused to apply a stylesheet because its hash, its nonce, or 'unsafe-inline' does not appear in the style-src directive of the Content Security Policy.
2022-09-02 08:56:13,686: Failed to connec to EGS (Status 401): {'errorCode': 'errors.com.epicgames.unauthorized', 'message': 'You are not authenticated. Please authenticate.', 'correlationId': 'f3b2b110-2a83-11ed-b1fa-b750a595f1e8'}
```
My system:
Fedora 34 KDE, 64 bit. Installed Lutris with `dnf` as instructed on the Lutris downloads page for Fedora.
These logs are the third start-up of Lutris. Each start-up I've had an attempt at logging into Epic Games.
I am experiencing the same issue and it seems to be related from this recent update.
Same issue here! I would appreciate a hotfix
2022-09-03 20:16:54,945: Failed to connec to EGS (Status 401): {'errorCode': 'errors.com.epicgames.unauthorized', 'message': 'You are not authenticated. Please authenticate.', 'correlationId': '355beea0-2bac-11ed-93a2-55f96b50b917'}

I am not familiar with the code . To me it seems that this process is handled in python. I could be completely wrong though. 

Looking at the code there it seems URLS need to be updated at least. I have a feeling though that the egs.py is just prototyping and not really apart of the lutris program.

Can anyone provide details?
It seems that this issue has already been fixed in the ["legendary" launcher](https://github.com/derrod/legendary/issues/468). The relevant commits there could be helpful:

* https://github.com/derrod/legendary/commit/5a20f1246187bb17eee84971b6bd4b515fe63494
* https://github.com/derrod/legendary/commit/b13674816826163d76537a7933b31d2bebc3ac5b
> It seems that this issue has already been fixed in the ["legendary" launcher](https://github.com/derrod/legendary/issues/468). The relevant commits there could be helpful:
> 
> * [derrod/legendary@5a20f12](https://github.com/derrod/legendary/commit/5a20f1246187bb17eee84971b6bd4b515fe63494)
> * [derrod/legendary@b136748](https://github.com/derrod/legendary/commit/b13674816826163d76537a7933b31d2bebc3ac5b)

yeah it looks like this is a fix and the code appears to be exact. So a copy paste/ cherry pick maybe might be enough. 


I want to ask , anyone know how to build this? 
same issue here. hope for a fix soon?

Hopefully there's a fix soon but as of this comment it has yet to be fixed. :(
Same issue :/ let's hope for a fix soon.
Having the same symptoms. I've tried starting lutris from the CLI to get some logs and here's what I've got:

```
$ lutris 
2022-09-02 08:55:44,068: Command /usr/sbin/lspci after 3 seconds
Gtk-Message: 08:55:44.652: Failed to load module "appmenu-gtk-module"
2022-09-02 08:55:44,654: Starting Lutris 0.5.10.1
2022-09-02 08:55:44,692: No folder at /home/XXX/.local/share/lutris/runners/retroarch/
2022-09-02 08:55:45,669: Running Intel Mesa driver 21.1.8 on Mesa Intel(R) HD Graphics 530 (SKL GT2) (0x191b)
2022-09-02 08:55:45,670: GPU: 8086:191B 1028:06E0 (i915 drivers)
2022-09-02 08:55:45,671: GPU: 1002:682B 1028:06E0 (radeon drivers)
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

2022-09-02 08:55:45,788: Startup complete

(lutris:358982): GLib-GIO-CRITICAL **: 08:55:46.061: g_dbus_proxy_new: assertion 'G_IS_DBUS_CONNECTION (connection)' failed
2022-09-02 08:55:51,833: EGS Token expired
2022-09-02 08:55:51,842: Error while completing task <bound method BaseService.reload of <egs.EpicGamesStoreService object at 0x7fdedddceb40 (lutris+services+egs+EpicGamesStoreService at 0x558a74343e40)>>: <class 'lutris.services.base.AuthTokenExpired'> 
  File "/usr/lib/python3.9/site-packages/lutris/util/jobs.py", line 34, in target
    result = self.function(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/lutris/services/base.py", line 96, in reload
    self.load()
  File "/usr/lib/python3.9/site-packages/lutris/services/egs.py", line 323, in load
    raise AuthTokenExpired from ex
Gtk-Message: 08:55:52.142: Failed to load module "appmenu-gtk-module"
https://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect:1:164: CONSOLE RENDERING ERROR Viewport argument key "minimal-ui" not recognized and ignored.
https://www.epicgames.com/id/api/redirect:1:1: CONSOLE SECURITY ERROR Refused to apply a stylesheet because its hash, its nonce, or 'unsafe-inline' does not appear in the style-src directive of the Content Security Policy.
2022-09-02 08:56:13,686: Failed to connec to EGS (Status 401): {'errorCode': 'errors.com.epicgames.unauthorized', 'message': 'You are not authenticated. Please authenticate.', 'correlationId': 'f3b2b110-2a83-11ed-b1fa-b750a595f1e8'}
```
My system:
Fedora 34 KDE, 64 bit. Installed Lutris with `dnf` as instructed on the Lutris downloads page for Fedora.
These logs are the third start-up of Lutris. Each start-up I've had an attempt at logging into Epic Games.
I am experiencing the same issue and it seems to be related from this recent update.
Same issue here! I would appreciate a hotfix
2022-09-03 20:16:54,945: Failed to connec to EGS (Status 401): {'errorCode': 'errors.com.epicgames.unauthorized', 'message': 'You are not authenticated. Please authenticate.', 'correlationId': '355beea0-2bac-11ed-93a2-55f96b50b917'}

I am not familiar with the code . To me it seems that this process is handled in python. I could be completely wrong though. 

Looking at the code there it seems URLS need to be updated at least. I have a feeling though that the egs.py is just prototyping and not really apart of the lutris program.

Can anyone provide details?
It seems that this issue has already been fixed in the ["legendary" launcher](https://github.com/derrod/legendary/issues/468). The relevant commits there could be helpful:

* https://github.com/derrod/legendary/commit/5a20f1246187bb17eee84971b6bd4b515fe63494
* https://github.com/derrod/legendary/commit/b13674816826163d76537a7933b31d2bebc3ac5b
> It seems that this issue has already been fixed in the ["legendary" launcher](https://github.com/derrod/legendary/issues/468). The relevant commits there could be helpful:
> 
> * [derrod/legendary@5a20f12](https://github.com/derrod/legendary/commit/5a20f1246187bb17eee84971b6bd4b515fe63494)
> * [derrod/legendary@b136748](https://github.com/derrod/legendary/commit/b13674816826163d76537a7933b31d2bebc3ac5b)

yeah it looks like this is a fix and the code appears to be exact. So a copy paste/ cherry pick maybe might be enough. 


I want to ask , anyone know how to build this? 
same issue here. hope for a fix soon?

Hopefully there's a fix soon but as of this comment it has yet to be fixed. :(
Same issue :/ let's hope for a fix soon.

Resolving patch:
diff --git a/lutris/services/egs.py b/lutris/services/egs.py
--- a/lutris/services/egs.py
+++ b/lutris/services/egs.py
@@ -150,7 +150,7 @@ class EpicGamesStoreService(OnlineService):
     cookies_path = os.path.join(settings.CACHE_DIR, ".egs.auth")
     token_path = os.path.join(settings.CACHE_DIR, ".egs.token")
     cache_path = os.path.join(settings.CACHE_DIR, "egs-library.json")
-    login_url = "https://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect"
+    login_url = "https://www.epicgames.com/id/login?redirectUrl=https%3A//www.epicgames.com/id/api/redirect%3FclientId%3D34a02cf8f4414e29b15921876da36f9a%26responseType%3Dcode"
     redirect_uri = "https://www.epicgames.com/id/api/redirect"
     oauth_url = 'https://account-public-service-prod03.ol.epicgames.com'
     catalog_url = 'https://catalog-public-service-prod06.ol.epicgames.com'
@@ -200,28 +200,9 @@ def login_callback(self, content):
         logger.debug("Login to EGS successful")
         logger.debug(content)
         content_json = json.loads(content.decode())
-        session_id = content_json["sid"]
-        _session = requests.session()
-        _session.headers.update({
-            'X-Epic-Event-Action': 'login',
-            'X-Epic-Event-Category': 'login',
-            'X-Epic-Strategy-Flags': '',
-            'X-Requested-With': 'XMLHttpRequest',
-            'User-Agent': self.user_agent
-        })
-
-        _session.get('https://www.epicgames.com/id/api/set-sid', params={'sid': session_id})
-        _session.get('https://www.epicgames.com/id/api/csrf')
-        response = _session.post(
-            'https://www.epicgames.com/id/api/exchange/generate',
-            headers={'X-XSRF-TOKEN': _session.cookies['XSRF-TOKEN']}
-        )
-
-        if response.status_code != 200:
-            logger.error("Failed to connec to EGS (Status %s): %s", response.status_code, response.json())
-            return
+        session_id = content_json["authorizationCode"]
 
-        self.start_session(response.json()['code'])
+        self.start_session(authorization_code=session_id)
         self.emit("service-login")
 
     def resume_session(self):
@@ -235,21 +216,24 @@ def resume_session(self):
             raise RuntimeError(response_content)
         return response_content
 
-    def start_session(self, exchange_code=None):
+    def start_session(self, exchange_code=None, authorization_code=None):
         if exchange_code:
-            grant_type = 'exchange_code'
-            token = exchange_code
+            params = dict(grant_type='exchange_code',
+                          exchange_code=exchange_code,
+                          token_type='eg1')
+        elif authorization_code:
+            params = dict(grant_type='authorization_code',
+                          code=authorization_code,
+                          token_type='eg1')
         else:
-            grant_type = 'refresh_token'
-            token = self.session_data["refresh_token"]
+            params = dict(grant_type='refresh_token',
+                          refresh_token=self.session_data["refresh_token"],
+
+                          token_type='eg1')
 
         response = self.session.post(
             'https://account-public-service-prod03.ol.epicgames.com/account/api/oauth/token',
-            data={
-                'grant_type': grant_type,
-                grant_type: token,
-                'token_type': 'eg1'
-            },
+            data=params,
             auth=self.http_basic_auth
         )
         if response.status_code >= 500:


Test patch: