#What should I use to check if user is logged after oAuth login

19 messages · Page 1 of 1 (latest)

iron vessel
#

Hi,

I'm trying to do oAuth login by google in my Flutter app. And I still have a problem with logging on the application side.
After logging in to google, I see in the Appwrite panel that an account and session have been created.

Should I then use the method:
account.get() or account.getSession('current') to check if the user is actually logged in? and move to the appropriate screen.

When I use the account.getSession('current') method I get the right data, but when I use account.get() I get error 401 (missing scope).

half linden
iron vessel
#

Hi, I realized that only happens in the mobile version. In the web version, when in the createOAuth2Session method I have the appropriate page passed in the success parameter, everything seems to be ok - logging in and logging out.
However, in the mobile version, after logging in, a page appears for a moment with information about the missing of redirect url, but then the get() method returns the appropriate data and I log in the user. On the other hand, the problem seems to occur the next time the get() method is called, before the user logs out. Both the deleteSession(sessionId: 'current') and get methods return me a 401 error as if there is no session created, but there is.

#

Should I also use success parameter in Flutter for mobile?

half linden
iron vessel
#

Sorry. Logout doesn't work. in 1st screen I marked result of the getAccoutInfo() method which is basically account.get() method. It's ok.
But when I want to logout (2nd screen) I get error 401 from the same previous method. I don' know why. I send You 2 additional screen with AppwriteService class and Main function where I init it.

half linden
iron vessel
#

I have the same code for web and mobile. Only difference is using success url for oAuth method in Web version. I don't use it in mobile. In Web everything works fine - login and logout

half linden
iron vessel
#

Yes. It shows for a moment and then is redirected automatically

half linden
iron vessel
#

I hope you meant this:)

#

and this is whole log from the beginning. First login and check session- it's ok. And next accout.get() and delete session - not ok

#

I think I know where the problem could be.
I did the test again. But this time I only cleared the application data, deleted the account and session in the Appwrite panel, but did not clear the data of the Chrome browser on the phone, which had previously saved the login data. Now after logging again, logging out worked as well. It may be related to the fact that the data is stored in the browser?

half linden
iron vessel
#

Yes. In web everything is ok. But problem is still with logout in mobile, but only when I login by google oAuth first time (when google credential are not yet remembered in Chrome). When I try to logout right after login I get an error 401. When I repeat the same action, but with previously remembered credential everything is ok. I can login and right after also logout

half linden
half linden