Back

User (role: guests) missing scope (account) using Oauth to check login status

  • 0
  • Auth
  • Web
Sikandar
13 Jun, 2024, 01:36

hi, I am always getting this error when using OAuth google login to check if user is logged in or not.

Workflow: I have this authContext function which in useEffect/useLayoutEffect gets current session and loads user's google profile if logged in else redirects to /login page. When a user is logged in, it works fine else it throws this exception (see title).

I have tried both account.get and account.getSession('current') and still gets the same exception when user is not logged in. This doesn't only happen in useEffect or useLayoutEffect on button to get session (just for testing) and its same.

useLayoutEffect(() => { getLoggedInGoogleUser(); }, []); const getLoggedInGoogleUser = async () => { try { const hey = await account.getSession("current"); if (hey) console.log(hey); } catch (error) { console.log(error); } };

please help getting around this error.

thank you, best regards.

TL;DR
Developers are encountering an error with OAuth Google login when attempting to check login status using the account scope. They have tried different approaches but are still facing the same exception when the user is not logged in. The provided code snippet shows the logic being used. One possible solution could involve checking the response from the account.getSession("current") call more thoroughly to handle cases where the user is not logged in.
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