Flutter Developer
I have this function in my auth file for logging in via google
Future loginWithGoogle() async {
try {
final result = await FlutterWebAuth2.authenticate(
url:
'https://fra.cloud.appwrite.io/v1/account/sessions/oauth2/google?project=685d2b28003a614fa813',
callbackUrlScheme: 'com.example.xhale',
);
final uri = Uri.parse(result);
final sessionId =
uri.fragment
.split('&')
.firstWhere((e) => e.startsWith('sessionId='))
.split('=')[1];
await widget.account.updateSession(sessionId: sessionId);
final user = await widget.account.get();
final userId = user.$id;
final email = user.email;
final name = user.name;
final userNotifier = ref.read(userProvider.notifier);
final exists = await userNotifier.checkIfUserExists(userId);
if (exists) {
await userNotifier.fetchUserData(userId);
if (!mounted) return;
Navigator.pushReplacement(
context,
MaterialPageRoute(builder: (_) => HomePage(account: widget.account)),
);
} else {
await userNotifier.createNewUser(
userId: userId,
email: email,
name: name,
phoneNumber: null,
);
if (!mounted) return;
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder:
(_) => InitialSmokingPreferencesPage(
account: widget.account,
email: email,
name: name,
phoneNumber: null,
),
),
);
}
} catch (e) {
debugPrint('❌ Google login error: $e')
}
}
The AndroidManifest file and the google cloud client are configured, but after I pick the account, i stay stuck at the 'https://fra.cloud.appwrite.io/v1/console/auth/oath2/success?project=685d2b28003a614fa813' and not redirected to my app. Why?