Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh GOG access token on error #294

Closed
sudonikgr opened this issue Aug 12, 2019 · 7 comments
Closed

Refresh GOG access token on error #294

sudonikgr opened this issue Aug 12, 2019 · 7 comments

Comments

@sudonikgr
Copy link

I suggest a 'check/uncheck' option that will do the following: Every time the user opens Gamehub, the folder "com.github.tkashkin.gamehub" in home/.cache will be automatically be deleted right before the application opens and right after the application is closed.

The reason for this suggestion is the following: almost every time I leave Gamehub open to download games or just do nothing and simply be open, it stops responding after a while. The "install" button becomes disabled after some time, or the details windows won't open, weird stuff. Even if I close and open the app again, the weird problems are still there. But I noticed that if I delete the "com.github.tkashkin.gamehub" folder in home/.cache the problems are gone when I re-open Gamehub. So that option would be very convenient for users who have the same problem.

Now, about the reason of the problem: in Ubuntu settings - Privacy I have enabled the option to automatically purge temporary files after 1 hour. So, maybe that's the reason. But I want to keep that option enabled, so my suggestion could work. If anyone else has that option in Ubuntu and have the same problem in Gamehub, maybe that's it.

@sudonikgr sudonikgr changed the title Option to delete the home/.cache subfolder Option to delete the home/.cache subfolder 'com.github.tkashkin.gamehub' Aug 12, 2019
@tkashkin
Copy link
Owner

That is weird. Does it just appear when GameHub is running for a long time or is there something else to reproduce it?

Your suggestion will just hide the underlying problem instead of fixing it.

~/.cache/com.github.tkashkin.gamehub/gamehub.db can help to debug this if database is somehow corrupted.

@sudonikgr
Copy link
Author

sudonikgr commented Aug 12, 2019

Screenshot from 2019-08-13 02-03-25
I found it! You were right, the database helped! In the screenshot you can see the two games that currently have problem: Treasure Adventure Game and Sunrider: Mask of Arcadius. For both games the message in the 'info_detailed' is "{"error":"invalid_grant","error_description":"The access token provided has expired."}" The install button is disabled.
I think that the problem occurs while a game is verifying data after download and then some other game is selected or double-clicked at the time of verification. I will try again and again until I am sure.

@tkashkin
Copy link
Owner

It looks like GOG access token is not refreshed on error but is refreshed on app start.
GOG access tokens have limited lifetime and have to be refreshed.

I think this bug was introduced recently. Previously parser did return null for failed requests and info_detailed field wasn't updated in database on error. Now it returns response as is and it's saved in database.

@sudonikgr
Copy link
Author

Ah so it's a bug then. Can I do something to fix it? Maybe I can delete the error message and re-open Gamehub?

@tkashkin
Copy link
Owner

tkashkin commented Aug 12, 2019

It's a bug. Now you can either select affected games in list view with Ctrl + click and use Refresh or remove affected games from database manually.
It will happen again if you try to interact with GOG games to trigger refresh for the first time after GameHub has been already running for an hour.

@sudonikgr
Copy link
Author

The ctrl+click and refresh worked! OK I will remember that and thank you for the solution!

@tkashkin tkashkin changed the title Option to delete the home/.cache subfolder 'com.github.tkashkin.gamehub' Refresh GOG access token on error Aug 12, 2019
@tkashkin
Copy link
Owner

@loaderini now (dfab162) GameHub should try to refresh GOG access token if request returns error 401 and then retry request.

You can test if it actually works:

  • Run com.github.tkashkin.gamehub --debug --log-auth in terminal
  • Leave it running for at least an hour
  • Try to do something with GOG games to trigger update

If --log-auth is passed GameHub will output debug messages when refreshing token:

[DEBUG]  [Auth] Refreshing GOG access token with refresh token: <old_refresh_token>
[DEBUG]  [Auth] GOG access token: <new_access_token>
[DEBUG]  [Auth] GOG refresh token: <new_refresh_token>
[DEBUG]  [Auth] GOG user id: <user_id>

hagabaka pushed a commit to hagabaka/GameHub that referenced this issue Aug 23, 2019
Lucki pushed a commit to Lucki/GameHub that referenced this issue Oct 30, 2021
Lucki pushed a commit to Lucki/GameHub that referenced this issue Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants