From ffbf83470114eec4bde089432da7b8b37c7a2a8f Mon Sep 17 00:00:00 2001 From: Patrick S <49350930+pBlackCreek@users.noreply.github.com> Date: Thu, 20 Mar 2025 10:59:12 +0000 Subject: [PATCH] Fix tokens not refreshing when loading session or refreshing token --- Gotrue/Client.cs | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Gotrue/Client.cs b/Gotrue/Client.cs index 544ceeb..313fae3 100644 --- a/Gotrue/Client.cs +++ b/Gotrue/Client.cs @@ -595,21 +595,13 @@ public async Task SetSession(string accessToken, string refreshToken, b if (CurrentSession == null) return null; - // Check to see if the session has expired. If so go ahead and destroy it. - if (CurrentSession != null && CurrentSession.Expired()) - { - _debugNotification?.Log($"Loaded session has expired"); - DestroySession(); - return null; - } - // If we aren't online, we can't refresh the token if (!Online) { throw new GotrueException("Only supported when online", Offline); } - // We have a session, and hasn't expired, and we seem to be online. Let's try to refresh it. + // We have a session, and we seem to be online. Let's try to refresh it. if (Options.AutoRefreshToken && CurrentSession?.RefreshToken != null) { try @@ -712,9 +704,6 @@ public async Task RefreshToken() if (CurrentSession == null || string.IsNullOrEmpty(CurrentSession?.AccessToken) || string.IsNullOrEmpty(CurrentSession?.RefreshToken)) throw new GotrueException("No current session.", NoSessionFound); - if (CurrentSession!.Expired()) - throw new GotrueException("Session expired", ExpiredRefreshToken); - var result = await _api.RefreshAccessToken(CurrentSession.AccessToken!, CurrentSession.RefreshToken!); if (result == null || string.IsNullOrEmpty(result.AccessToken))