Back

oAuth Flutter redirect re-opens app

  • 0
  • Flutter
Ahmed Hammad
14 Oct, 2024, 20:04

Hi there , I updated flutter sdk and appwrite from 0.15 to latest

Needed to do some changes for flutter code for sure but I faced a new problem in auth , after the google auth , the auth happens and shows at my console sessions , so it works fine .. but when it re-direct to my flutter app again after oauth, the app re-opens again showing splash screen again .. I have a check in my app if user is logged in open home screen , if not show login screen by checking get.account() at main, But it opens login screen every time I open the app , so I don't know where is the problem , auth happens on console , but when app do get.account() it doesn't retrun any sessions ,

problems :- 1- the redirect after oauth re-open the app showing splash screen 2- if I closed the app and opened it again the get.account() can't hear the session that already happened and showed at my console sessions .

want refer to that code works fine for email and password login so no problem in code ..

and even oauth that had a problem worked well from 0.8 appwrite to 0.15

check if user logged In or not ,, to choose home at myapp later .. works fine for email password auth .

TypeScript
userSigned = await account.get();
        isLoggedIn = true;
        client.addHeader("serverId", userSigned.$id);
      } on AppwriteException {
        isLoggedIn = false;
      }
    }

    runApp(const MyApp());

oauth code

TypeScript
        Future<dynamic> oAuthAccount =
         account.createOAuth2Session(
            provider: OAuthProvider.google
        );
        Future.delayed(Duration(seconds: 1), () async {
          userSigned = await account.get();
          return oAuthAccount;
        });
TL;DR
- Developer updated Flutter SDK and Appwrite, facing issue where app re-opens showing splash screen after Google OAuth. - Console shows authentication sessions, but `get.account()` doesn't return sessions in the app. - Existing email/password login works fine. - Solution: Ensure the `get.account()` function properly handles OAuth sessions to avoid re-opening the app and not recognizing existing sessions.
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