Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: oAuth Flutter not working correctly , it re-opens app after redirecting . #219

Open
2 tasks done
AhmedHammad0900 opened this issue Oct 15, 2024 · 1 comment
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@AhmedHammad0900
Copy link

AhmedHammad0900 commented Oct 15, 2024

👟 Reproduction steps

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 .

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

    runApp(const MyApp());

oauth code

 Future<dynamic> oAuthAccount =
         account.createOAuth2Session(
            provider: OAuthProvider.google
        );
        Future.delayed(Duration(seconds: 1), () async {
          userSigned = await account.get();
          return oAuthAccount;
        });
 

👍 Expected behavior

to redirect to same page of login screen then I can account.get() ;

👎 Actual Behavior

it reopens the app showing splash screen and account.get() can't work like authentication didn't happen , while it already happened at console , and can't access documents so no auth token .

🎲 Appwrite version

Version 2.0.x

💻 Operating system

Linux

🧱 Your Environment

custom server working with nginx .

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@AhmedHammad0900 AhmedHammad0900 added the bug Something isn't working label Oct 15, 2024
@stnguyen90
Copy link
Contributor

@AhmedHammad0900,. thanks for creating this issue! 🙏🏼

worked well from 0.8 appwrite to 0.15

What versions are you referring to? Appwrite instance or the Appwrite Flutter SDK?

 Future<dynamic> oAuthAccount =
         account.createOAuth2Session(
            provider: OAuthProvider.google
        );
        Future.delayed(Duration(seconds: 1), () async {
          userSigned = await account.get();
          return oAuthAccount;
        });

I don't quite understand this snippet you shared. Why aren't you awaiting the createOAuth2Session()?

Also, would you please share:

  1. if you're using Appwrite Cloud or self hosting
  2. If you're self hosting, what version of Appwrite do you have
  3. what version of the Appwrite Flutter SDK you have

@stnguyen90 stnguyen90 self-assigned this Dec 18, 2024
@stnguyen90 stnguyen90 added the question Further information is requested label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants