Bug report: Race condition in Flutter SDK `createOAuth2Session` / `client_io.dart
- 0
- Flutter
- Auth
Hi team,
I've found an intermittent bug in the Flutter SDK (v20.3.0) when using createOAuth2Session on Android.
Symptoms
After createOAuth2Session resolves, an immediate call to _account.get() intermittently throws:
AppwriteException: general_unauthorized_scope,
User (role: guests) missing scopes (["account"]) (401)
Root cause
In client_io.dart, the webAuth method resolves the Future immediately after:
_cookieJar.saveFromResponse(Uri.parse(_endPoint), cookies);
saveFromResponse is an async write operation that may not have fully persisted the session cookies by the time the caller makes the next API call. This creates a race condition between cookie persistence and subsequent authenticated requests.
Reproduction
- Android device
- OAuth2 provider: Google
- Call
createOAuth2Sessionfollowed immediately by_account.get() - Intermittent in debug mode, less frequent in release mode
Workaround
Retry _account.get() with exponential backoff after a 401 response.
Suggested fix
Ensure saveFromResponse is fully awaited and the cookie jar is flushed before resolving the Future in webAuth.
Recommended threads
- [SOLVED] Appwrite 25.1.0 returns Invalid...
I've already opened an issue on GitHub, but somewhat it doesn't seem like GitHub is monitored very closely, so I'm leaving a bug report here on Discord as well....
- Student plan issue
I am using GitHub student plan, I even got access to appwrite's mock phone number. but when I try to use it, it says the phone number limit has reached
- Getting "The current user has been block...
So today I want to deploy something to Appwrite but when I click Sign in with Github, it's redirect me to login site and in the url bar I see this `?error=%7B"m...