Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auth sessions don't automatically refresh #52

Open
MilesV64 opened this issue Apr 20, 2023 · 2 comments
Open

Auth sessions don't automatically refresh #52

MilesV64 opened this issue Apr 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@MilesV64
Copy link
Contributor

Bug report

Describe the bug

When calling try await client.auth.session, it often throws GoTrue.GoTrueError.APIError(message: nil, msg: nil, code: nil, error: Optional("invalid_grant"), errorDescription: Optional("Invalid Refresh Token: Refresh Token Not Found") and I need to manually sign in again. This happens quite often and is undesirable behavior in a production iOS app, as the user should not have to sign back in so often.

To Reproduce

  1. Sign in with OTP sms
  2. Make plenty of authenticated server requests like so:
do {
    let session = try await self.supabaseClient.auth.session
    let accessToken = session.accessToken
    // Pass accessToken in http authorization header to custom server endpoint
}
  1. Eventually, after a day or so, the auth session will start throwing the refresh token error.

Expected behavior

The user should not have to log in again ever on iOS, unless they log out themselves. Meaning if you have logged in, try await client.auth.session should always refresh itself and give a valid session assuming no other errors.

System information

  • OS: [iOS 16.4.1]
  • Version of gotrue-swift: [e.g. 1.1.0]
  • Version of supabase-swift: [e.g. 0.2.1]
@MilesV64 MilesV64 added the bug Something isn't working label Apr 20, 2023
@MilesV64
Copy link
Contributor Author

Curious if this is happening to anyone else? This may be a supabase auth server bug, but every time the session attempts to refresh I get this error.

@grdsdev grdsdev self-assigned this Oct 17, 2023
@pradeepb28
Copy link

it is happening to me for SignInWithOTP via email as well. Session expires but doesn't retrieve new ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants