supabase-swift
supabase-swift copied to clipboard
feat(auth): auto refresh token
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.
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.
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
manualoption by default.
My bad. I see it was added as configuration field. But I believe I should be false by default.
Closed in favor of https://github.com/supabase/supabase-swift/pull/395