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
- general_route_not_found - Auth Guide
If you’ve just added a subdomain to your project, verified your DNS records, and confirmed your SSL certificate is working, but you're still hitting a `general_...
- Impossible to get USER after createEmail...
Am using provider to deal with functions linked to appwrite. Here is my login. Future<String?> login(String email, String password) async { try { aw...
- User ID case sensitivity
I see that through REST (and SDK as well), getting a user is not case sensitive. And even though documentation does not clearly state that it is, the wording "V...