Import Games dialog not opening (GOG Error 401)

When clicking on the Import Games link, nothing comes up.

Opening Lutris from command line, here’s the output:

2019-11-09 13:18:00,615: Failed to get token, check your GOG credentials
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/lutris/util/http.py", line 72, in get
    request = self.opener.open(req, timeout=self.timeout)
  File "/usr/lib/python3.7/urllib/request.py", line 531, in open
    response = meth(req, response)
  File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python3.7/urllib/request.py", line 569, in error
    return self._call_chain(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/lutris/gui/lutriswindow.py", line 188, in <lambda>
    "sync-local": Action(lambda *x: self.open_sync_dialog()),
  File "/usr/lib/python3.7/site-packages/lutris/gui/lutriswindow.py", line 519, in open_sync_dialog
    SyncServiceWindow(application=self.application)
  File "/usr/lib/python3.7/site-packages/lutris/gui/widgets/services.py", line 330, in __init__
    sync_row = ServiceSyncBox(service, self)
  File "/usr/lib/python3.7/site-packages/lutris/gui/widgets/services.py", line 53, in __init__
    self._connect_button_toggle()
  File "/usr/lib/python3.7/site-packages/lutris/gui/widgets/services.py", line 144, in _connect_button_toggle
    if self.service.is_connected():
  File "/usr/lib/python3.7/site-packages/lutris/services/gog.py", line 256, in is_connected
    return GOG_SERVICE.is_available()
  File "/usr/lib/python3.7/site-packages/lutris/services/gog.py", line 70, in is_available
    user_data = self.get_user_data()
  File "/usr/lib/python3.7/site-packages/lutris/services/gog.py", line 169, in get_user_data
    return self.make_api_request(url)
  File "/usr/lib/python3.7/site-packages/lutris/services/gog.py", line 156, in make_api_request
    request.get()
  File "/usr/lib/python3.7/site-packages/lutris/util/http.py", line 77, in get
    raise UnauthorizedAccess("Access to %s denied" % self.url)
lutris.util.http.UnauthorizedAccess: Access to https://embed.gog.com/userData.json denied

So looks like the GOG token might be expired? Is there any way to reset/delete that token?

Using version 0.5.3

There is a small icon in the corner of the game import dialog, GOG tab. It has a disconnect function when logged in, a connect function to login. When Lutris registeres the account as logged in you should be able to disconnect and reconnect by using this buttons.

Re-reading your comment, the whole window closes on you? That shouldn’t be happening in my opinion. When a server responds with an error the best way for a program is to catch it and to reset the interface to the connect state again. This way the user can re-login.

Yep, the dialog window does not open for me. It’s like clicking the “Import Games…” link does nothing.

But thanks for the hint about disconnecting, I read the source code and found the functionality, it removes some authentication files. Removed those files manually and now it works!

So in case somebody else has this issue, you need to remove these three files:

CACHE_DIRECTORY/.gog.auth
CACHE_DIRECTORY/.gog.token
CACHE_DIRECTORY/gog-library.json