tylerbrawl / Galaxy-Plugin-Rockstar

MIT License
70 stars 7 forks source link

Still losing authentication #22

Closed k3lt closed 4 years ago

k3lt commented 4 years ago

I'm on v0.2.2 release, not sure how long it took to lose the authentication because the last time i run the GOG Galaxy client was few days ago, but the authentication is gone and i have to relogin again.

Edit: I'm not using 2fa.

tylerbrawl commented 4 years ago

Sadly, I noticed this issue with v0.2.2. Would you be able to try the latest pre-release for v0.3? I have an even newer version that might become the final release for v0.3, but I still wish to do some testing.

tylerbrawl commented 4 years ago

Here is the updated version in question. I personally have not lost authentication with this version after using it for a few hours, but I would appreciate your feedback before I consider it production ready. plugin-v0.3-rc.zip

k3lt commented 4 years ago

Ok, i'll let you know.

k3lt commented 4 years ago

Lost my authentication with the plugin you posted, not sure when exactly but in less than 19 hours. (since i posted)

tylerbrawl commented 4 years ago

Could you send me the log file for the plugin? It is located at C:\ProgramData\GOG.com\Galaxy\logs\plugin-rockstar-774732b5-69c4-405c-b6c9-92cd55740cfe.log. If you could, I would also appreciate you sending me this log as well as all older log files for the plugin as a .zip file.

k3lt commented 4 years ago

I have only 1 log. plugin-rockstar-774732b5-69c4-405c-b6c9-92cd55740cfe.zip

tylerbrawl commented 4 years ago

I believe I figured out what the issue is. I recall that during the very early days of the development of this plugin, I attempted to use aiohttp as I do now. The reason why I moved to Requests was because aiohttp.ClientSession and aiohttp.CookieJar do not update cookies automatically, whereas Requests did. When I moved back to aiohttp, I forgot this fact, and thus outdated cookies were left in the session.

To keep cookies updated, it turns out that you need to manually update the cookies, as follows:

response = await session.get(url)  # You can also use other request methods, like session.post(url).
filtered = response.cookies
if "cookie_name" in filtered:  # This is not necessarily required, but it will prevent potential KeyError throws.
    session.cookie_jar.update_cookies({"cookie_name": filtered["cookie_name"].value})

In short, the problem was not on your side; I was also dealing with outdated cookies, but I cannot recall losing authentication. Perhaps I was not logged in as long as you were. Regardless, brief testing shows that the cookies are now being updated correctly. Below is a modified version of the plugin with the proposed fix. Let me know how it works out for you.

plugin.zip

k3lt commented 4 years ago

Haven't lost authentication since yesterday so it might be the fix.

tylerbrawl commented 4 years ago

That's great to hear! Thanks again for reporting the issue in the first place. I will now close this issue, but if any other people have this issue, then they can post it here.