gotrue-csharp icon indicating copy to clipboard operation
gotrue-csharp copied to clipboard

Fix RefreshToken()

Open maverikou opened this issue 1 year ago • 3 comments

What kind of change does this PR introduce?

Refresh token never expires. Don't need to check for session expiration when refreshing. This fixes a bug making it impossible to recover a session after the client has been offline for longer than the expiry time of the access token.

What is the current behavior?

Can't use a refresh token beyond the expiry time of the access token.

What is the new behavior?

Client can now try to refresh the access token for as long as it holds the refresh token.

maverikou avatar Oct 08 '24 11:10 maverikou

Hi. I'm having the same issue here. Is there really any workaround ?

Are you saying this patch doesn't resolve the issue?

maverikou avatar Feb 03 '25 11:02 maverikou

I think this could solve #108

zalito12 avatar Mar 11 '25 09:03 zalito12

I tested this changes and, actually, it helps but it doesn't fully fix #108

I needed to make a change in RetrieveSessionAsync. Here it always destroys the session and never try to refresh:

if (CurrentSession != null && CurrentSession.Expired())
{
    _debugNotification?.Log($"Loaded session has expired");
    DestroySession();
    return null;
}

I changed it so it checks if autorefresh is activated, and now it works fine, autorefresh the token everytime I open the app and the session has expired:

if (CurrentSession != null && CurrentSession.Expired() && !Options.AutoRefreshToken)

zalito12 avatar Mar 12 '25 10:03 zalito12