supabase-swift icon indicating copy to clipboard operation
supabase-swift copied to clipboard

feat(auth): auto refresh token

Open grdsdev opened this issue 1 year ago • 2 comments

What kind of change does this PR introduce?

Fix https://github.com/supabase/supabase-swift/issues/77

What is the current behavior?

An access token is currently refreshed only when retrieved before calling an endpoint.

What is the new behavior?

A part of the behavior specified above, now periodically checks for the token in the background and refreshes it upfront, the same behavior as JS and Flutter libs.

grdsdev avatar Apr 23 '24 17:04 grdsdev

If we have infinite lifetime for the refresh token (according to docs) seems better to verify/refresh access token just on session touch (as it was initially implemented). Nobody knows when it will be used next time so looks strange to auto refresh it by default. At least we can introduce something like:

enum SessionRefreshStrategy {
    case manual, auto
}

with manual option by default.

ypotsiah avatar Apr 24 '24 14:04 ypotsiah

If we have infinite lifetime for the refresh token (according to docs) seems better to verify/refresh access token just on session touch (as it was initially implemented). Nobody knows when it will be used next time so looks strange to auto refresh it by default. At least we can introduce something like:

enum SessionRefreshStrategy {
    case manual, auto
}

with manual option by default.

My bad. I see it was added as configuration field. But I believe I should be false by default.

ypotsiah avatar Apr 24 '24 15:04 ypotsiah

Closed in favor of https://github.com/supabase/supabase-swift/pull/395

grdsdev avatar May 21 '24 13:05 grdsdev