Skip to content
Back

login With OAuth Failed

  • 0
  • 2
  • Flutter
  • Auth
  • Cloud
Zionnite
27 Jan, 2026, 03:01

login With OAuth Failed: when i cliick to login with any of the following (facebook, gmail or apple) am being redirected out of the app to enter my detail, after entering my details, i'm redirected back to my app, sometime before it redirected to my app i will get missing callback link,

  1. sometimes, it instead for it to open the app, it will forecfully go back to the oauth provider,
  2. There is never error output when i enter my login details: 3a. User detail is inserted into the db
  3. i have my domain name amongst the platform
  4. i have tested this on real device and it issues persists

here is my code:

TL;DR
Issue with OAuth login not working; seeking help and advice.
Zionnite
27 Jan, 2026, 03:01

Controller

TypeScript
  isLoading.value = true;
  try {
    await _appwrite.loginWithOAuth(provider);
    currentUserId.value = await _appwrite.getCurrentUserId();
    handlePostLogin();
  } catch (e) {
    Get.snackbar(
      'Error',
      e.toString(),
      duration: const Duration(seconds: 20),
    );
  } finally {
    isLoading.value = false;
  }
}```

*Service*

``` Future<void> loginWithOAuth(String provider) async {
  try {
    await account.createOAuth2Session(
      provider: _mapProvider(provider),
    );

    // :white_check_mark: Wait until Appwrite knows about the new session
    var user = await _waitForSession();
    String fullName = user.name ?? '';
    String username;

    if (fullName.trim().isEmpty) {
      fullName = _deriveNameFromEmail(user.email ?? '');
      username = fullName.split(' ').first;

      await account.updateName(name: fullName);

      // Refresh the user object to reflect the change
      user = await account.get();
    } else {
      username = fullName.split(' ').first;
    }

    await functions.createExecution(
      functionId: createProfileID,
      body: jsonEncode({
        'userId': user.$id,
        'username': user.$id,
        'fullName': fullName,
      }),
    );

    //insert the user to my php server
    await ApiService.createProfile(
      userId: user.$id,
      userName: user.$id,
      fullName: fullName,
      email: user.email,
      password: user.password.toString(),
    );

    //sharePreference
    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.setString('userId', user.$id);
    prefs.setBool('isUserLogin', true);
  } catch (e, s) {
    debugPrint('OAuth login error: $e\n$s');
    throw Exception('OAuth login failed');
  }
}```
Zionnite
27 Jan, 2026, 03:03
TypeScript
        <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="my-appwrite-call-back" />
            </intent-filter>
        </activity>```

```<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>CFBundleURLName</key>
            <string>io.appwrite</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>my-appwrite-callback</string>
            </array>
        </dict>
    </array>```
27 Jan, 2026, 09:58

any suggession here

27 Jan, 2026, 20:39

can someone through their weight around this issues

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more