Skip to content
Back

AppwriteException: User (role: guests) missing scope (account). PLEASE HELP :(

  • 1
  • Auth
  • Web
Albatross
26 May, 2025, 17:36

tired of this error, after clicking the signup button its redirecting but getting this error when accessing the session here is the code in the userContext it worked well before but its giving this error for few users REACT CODE

useEffect(() => { getUser(); }, []);

const getUser = async () => { try { setIsLoading(true); // console.log("Executing the getUser function");

TypeScript
  // Get the current session
  let session = await account.getSession("current");
  console.log(session, "this is session");
  // console.log(session, "this is the session");
  if (!session) {
    // console.log("No active session found");
    setUser(null);
    setIsLoading(false);
    return;
  }

  //@ts-ignore

  // Update session to refresh authentication
  const promise = account.updateSession("current");
  promise.then(
    function (response) {
      console.log(response); // Success
    },
    function (error) {
      console.log(error); // Failure
    }
  );
  // Get user details after refreshing session
  const userData = await account.get();
  setUser(userData);
  // console.log(userData, "This is the user");
} catch (error) {
  console.log("Failed to fetch user:", error);
  setUser(null);
} finally {
  setIsLoading(false);
}

};

and the login button const handleGoogleLogin = async () => { try { await account.createOAuth2Session( OAuthProvider.Google, "http://localhost:8080/", "http://localhost:8080/" ); } catch (error) { console.error("Google login failed", error); } };

TL;DR
Developers are facing an AppwriteException error with the message: "User (role: guests) missing scope (account)." The issue occurs for some users after clicking the signup button. The provided React code needs to be checked for any missing or incorrect scopes related to the role of guests. Additionally, the login button's handleGoogleLogin function involving OAuth2 might require closer examination for potential misconfigurations or issues causing the error.
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