issork / gift

Godot IRC For Twitch addon
MIT License
150 stars 23 forks source link

Is there a reason why the refresh token is not used? #28

Open agentilo opened 12 months ago

agentilo commented 12 months ago

Hi, just went through the code and saw that it is using the Authorization code grant flow for authenticating with twitch, which is great! But I am not sure, if I miss something here.

Your code checks, if the access token is still valid and if it isn't a signal is called but as far as I see, it does not try to get a new token by using the refresh token you got on authorization.

The authorize function also will always just newly authenticate to get an access token. If the file already exists (which should also include a refresh token) it could simply refresh the token, so the user does not have to open the browser everytime the game is started.

My take on this would be:

authorize function:

issork commented 12 months ago

Thanks! I do not remember why I didn't use the refresh token, so I'm assuming that this was an overlook on my end. Your proposal looks good to me.

JDDoesDev commented 11 months ago

Has there been any movement or PR on this issue? I think this is a great idea and should be added to an upcoming release

issork commented 10 months ago

Implemented in 0545456faa8537a86bb266fe1df8fd3d06505358 for the initial connection. If the token becomes invalid while the program is running, users will have to refresh it themselves with the new refresh_access_token method when the user_token_invalid signal is emitted.

Will keep this issue open until auto-refreshing after a failed API call is implemented as well.