Skip to content
Back

Flutter OAuth2 Google Login – Redirect Issue on Flutter (Android )

  • 0
  • Android
  • Flutter
  • Auth
  • Cloud
Sidali_dev
4 Oct, 2025, 21:21

i tried implementing OAuth2 Google Login in my app, and it works fine for the most part, the problem am facing is when i chose a google account to sign in/up with, i get navigated back to the screen where i choose an account to sign in/up with, thus creating an endless loop, i can break this loop by navigating back after any successful sign in/up, but i believe the app should redirect back to the app automatically on a successful sign in/up, i followed the docs, and added this activity:

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="appwrite-callback-68b4b7bb0033a245f7e0" />
        </intent-filter>
    </activity>

but it still not working, after searching the docs for a bit tho, i guess i should add a onSuccess and onFailure links in the .createOAuth2Session() function, so i bought a domain called "yashbook.online" just for this reason, and i did add it as a custom domain successfully, but now, i have no clue what should i do to finish setting it up, i tried looking for docs, but i couldnt find anything. btw here the function that am calling, just in case am making some mistake when calling it (which i doubt):

Future<User> loginWithGoogle() async { try { await _account.createOAuth2Session( provider: OAuthProvider.google, );

TypeScript
  await Future.delayed(Duration(milliseconds: 100));

  // After the session is created, fetch the user
  final user = await _account.get();
  _currentUser = user;

  _status = AuthStatus.emailVerified;
  return user;
} catch (e) {
  rethrow;
}

}

TL;DR
Developers facing an issue with Flutter OAuth2 Google Login where after choosing a Google account to sign in/up with, they get stuck in an endless loop instead of redirecting back to the app. They added CallbackActivity in the manifest file but it didn't resolve the problem. The possible solution might be to add onSuccess and onFailure links in the .createOAuth2Session() function. The developer also mentions purchasing a domain for this purpose but is unsure how to proceed.
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