Repository: lutris/lutris

Issue:
Impossible login to GOG.com: invalid cookie ?
**Describe the bug**

I can't connect Lutris with my GOG.com account: the GOG.com credentials window is here, I can fill it, but when I confirm this form, the window closes and… nothing more. My account isn't connected, and if I close the "Import games" window, I can't reopen it unless I delete '.cache/lutris' directory. 

**Expected behavior**

I should have a second GOG.com form asking for a PIN code, then my account should be connected in Lutris.

**Current behavior**

As in description above. Plus technical details:

* two files are created  in '~/.cache/lutris/': .gog.auth and .gog.token (attached as [gog.auth.txt](https://github.com/lutris/lutris/files/4309081/gog.auth.txt) and [gog.token.txt](https://github.com/lutris/lutris/files/4309083/gog.token.txt))
* according to standard output in terminal, some problems with Python, ending with an invalid cookie? (see [lutris.txt](https://github.com/lutris/lutris/files/4309117/lutris.txt))

**Steps to reproduce**

It happens while importing GOG games from the app or installing GOG games from the website.

**System information**

Fresh Lutris install, Arch Linux, kernel 5.5.8. More in [lutris.log](https://github.com/lutris/lutris/files/4309125/lutris.log)


Discussion:
Maybe a stupid question, but did you tried whit another account that does not have pin authentification ?

I don't have a GoG account so I can't test right now to check if you're not alone with this issue
When I logged out of gog in lutris yesterday I wasn't able to log back in and haven't been able since. The situations Manulnzesky has described are the same for me, and the terminal also gives the same errors.
Well Strycore made this commit 9 hours ago on the website (https://github.com/lutris/website/compare/8597df0e647e...b872c678ff9d) but I don't think it as to do with your problem I't might be a change on the GoG auth side.

Maybe a more experienced dev will have a better idea of what the root of the problem could be

I have no other account, but I tried after disabling double authentication from GOG.com. Exactly the same problem.
Nota: you don't have to delete the whole '.cache/lutris' directory to re-enable the "Import games" window, only '.cache/lutris/.gog.auth' is enough. But GOG authentication still fails.
Works for me on Manjaro: After entering the credentials, the 2FA form shows up and I can login successfully.
Same issue here on Ubuntu 20.04.

Can login to GOG through the 'Import Games' dialog, but the games don't load up. If I close the 'Import Games' dialog, I can no longer open it back up unless I delete the .gog.auth file. There's an error in the output:

`OSError: invalid Netscape format cookies file '/home/lewis/.cache/lutris/.gog.auth': 'login.gog.com\tFALSE\t/\tTRUE\[token]\tgalaxy-login-s\[token]\tNone'`

The source of the error seems to be:

```
DEBUG    2020-03-12 15:33:19,670 [gog.load_cookies:111]:Loading cookies from /home/lewis/.cache/lutris/.gog.auth
/usr/lib/python3/dist-packages/lutris/util/cookies.py:79: UserWarning: http.cookiejar bug!
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/lutris/util/cookies.py", line 31, in _really_load
    domain, domain_specified, path, secure, expires, name, value = line.split(
ValueError: too many values to unpack (expected 7)
```

So it looks like the cookie format has changed on the GOG side, possibly?

The auth file contains:

`#HttpOnly_login.gog.com	FALSE	/	TRUE	[token]	galaxy-login-s	[token]	None`

Which is 8 values long, and lutris is expecting 7. Is the comment at the start getting added for some reason?
Hi all.

I was checking this, trying to find a workaround the issue, and i've found one:

In the file mentioned above (~/.cache/lutris/.gog.auth), remove the last part of the connection strings demonstrated there. In my case, I've removed a "None" token, as well as the TAB char before it.

Saved the file, and tried to open the Import Games dialog again, and it worked fine.

Seems like python is expecting to split the string using '\t' char, and expects 7 strings as a result, but maybe something changed on GOG side, and a new parameter is passed (The "None").

I"m not sure how secure this WA is, but seems to be working fine here.
Issue seems to be on the following line, in the 'cookies.py' file. But I'm not sure how to actually fork and suggest a fix. Kinda new to GitHub.

https://github.com/lutris/lutris/blob/c5c57ba65ea76668258f38a9539557f0812f2a44/lutris/util/cookies.py#L31

I believe we should simply add a new variable after "value", to hold the new token.

Resolving patch:
diff --git a/lutris/util/cookies.py b/lutris/util/cookies.py
--- a/lutris/util/cookies.py
+++ b/lutris/util/cookies.py
@@ -28,7 +28,7 @@ def _really_load(self, f, filename, ignore_discard, ignore_expires):
                 elif sline.startswith("#") or sline == "":
                     continue
 
-                domain, domain_specified, path, secure, expires, name, value = line.split(
+                domain, domain_specified, path, secure, expires, name, value, aditional_info = line.split(
                     "\t"
                 )
                 secure = secure == "TRUE"


Test patch: