Back

AppwriteException: User (role: guests) missing scope (account)

  • 1
  • Auth
  • Web
taheridevelopers
29 Jul, 2024, 06:31

I am getting this error even after the user is logged In

https://cloud.appwrite.io/v1/account 401 (Unauthorized)

TypeScript
    try {
      const userData = await account.get();
      setUser(userData);
      console.log("USERDATAAAAAAAAAAA", userData);


      if (userData) {
        router.replace("/");
        window.location.reload();
      }
      setLoading(false);
    } catch (error) {
      console.log(error);
      setLoading(false);
    }
  };

The above function was to check and fetch userData (User Is already signed In till here)

Below is my appwriteConfgi code

TypeScript

const client = new sdk.Client()
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject("ProjectId")
  .setKey(
    "apiKey"
  );

export const account = new sdk.Account(client);
export const users = new sdk.Users(client);
export const storage = new sdk.Storage(client);
export const databases = new sdk.Databases(client);

(Have removed APi key and projectId as of now for posting)

TL;DR
Developers are encountering an AppwriteException: User (role: guests) missing scope (account) error despite successful user login. The issue persists even after the user is logged in. The error message appears as a 401 (Unauthorized) on the Appwrite Cloud platform. The checkUserStatus function is successfully fetching user data, indicating a successful sign-in, and then the user is directed to the main page. However, the error occurs during this process. The appwriteConfig code snippet is provided for context, with API key and Project ID removed for the post. The developers are using the provided code for user authentication and fetching user data
taheridevelopers
29 Jul, 2024, 06:33
TypeScript
  const result = await account.createEmailPasswordSession(
    email, // email
    password // password
  );

  return result;
};```

This is what i am using to log in the user
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