
What I Wanted- I am making an app where I have a button "Signin with google" where clicking on it will redirect me to google account page and select and account there. When it is successful it will navigate to BoardWindow.
What happens- When I click on the "Sign in with google button" it redirects me to google account page. When I select an account it shows appwrite logo then again goes to google account page. And this loop keeps repeating.
Code-
@override
void initState() {
super.initState();
checkLoginStatus();
}
Future<void> checkLoginStatus() async {
if (await isLoggedIn()) {
print('logged in');
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => BoardWindow(account: account),
),
);
});
} else {
print("logged out");
}
}
Future<void> signInWithGoogle(BuildContext context) async {
try {
await account.createOAuth2Session(provider: OAuthProvider.google);
// Wait for login to complete and then check session
await Future.delayed(Duration(seconds: 2)); // Let redirect complete
if (await isLoggedIn()) {
// If login was successful, go to BoardWindow
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => BoardWindow(account: account)),
);
}
} catch (e) {
print("OAuth login error: $e");
}
}
ElevatedButton(
onPressed: () {
signInWithGoogle(context);
},
I have also added the activity code for AndroidManifest.xml with project-id in appwrite...
what am i doing wrong?

For anyone facing this issue
Hi everyone! I also ran into this issue today, and I think I managed to solve it.
I updated the flutter_web_auth_2 package to the latest version 5.0.0-alpha.1.
You can do this by adding the following to your pubspec.yaml under dependency_overrides:
dependency_overrides:
flutter_web_auth_2: 5.0.0-alpha.1
I also found this recommendation in the flutter_web_auth_2 package description:
There is also a known problem with task affinities and launch modes (see #113). In order to ensure that flutter_web_auth_2 works correctly, set android:launchMode="singleTop" and remove any android:taskAffinity entries. This configuration is guaranteed to work.
```
Courasy by Egor Tabula

You can solve the flutter_web_auth_2 problem by following this issue. https://discord.com/channels/564160730845151244/1334415894394306571/1334427575790997546
Recommended threads
- Global Variables
I'm building a Azure DevOps Pipeline Task to deploy my functions to Appwrite using REST APIs. How can I set project global variables via REST? This endpoint do...
- "Memberships privacy" setting in 1.7.4
Hi everyone, I'm experiencing an issue with a clean self-hosted installation of Appwrite version 1.7.4. I previously used version 1.6.1, and if I remember corre...
- Avoiding 409 user_already_exists When Mi...
We’ve migrated all our existing email+password users into Appwrite and now want to switch entirely to OAuth (Google & Apple) for authentication. Our plan is th...
