Google Oath2 for Flutter Android App not redirecting back to the app after successful authentication
- 0
- Android
- Flutter
- Auth

I have this function in my auth file for logging in via google Future<void> 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?

I will add the relevant AndroidManifest.xml code here for reference: <activity android:name=".MainActivity" android:enableOnBackInvokedCallback="true" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme" /> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <!-- CallbackActivity για Google Sign-In -->
<!-- Add this inside the <application> tag, along side the existing <activity> tags --> <activity android:exported="true"
android:name="com.linusu.flutter_web_auth_2.CallbackActivity">
<intent-filter android:label="flutter_web_auth_2">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="com.example.xhale" android:host="callback" />
</intent-filter>
</activity>

What is the scheme you are using?
Recommended threads
- I am facing this error: type 'Null' is ...
When attempting to fetch areas from the area collection, the application throws an error: "type 'Null' is not a subtype of type 'int.'" This issue originates in...
- Adding Domain to Sites [Self Hosted]
I am struggling to get this working. I stood-up a new server and deployed appwrite 1.7.4. I added update .env file _APP_DOMAIN=appwrite.mydomain.com _APP_DOMAI...
- Auth ( OTP Session )
Hi, i would like to ask about OTP session login, may i know is it doable for dynamic/variable for sender,reply-to or not?
