Back

AppwriteException: User (role: guests) missing scope (account) How do i solve this issue

  • 0
  • React Native
  • Auth
  • Databases
  • Web
benedict_t
8 Jan, 2025, 11:11

Please how do i solve this issue?

Below is my code

export const createUser = async (username, email, password) => { try { const newAccount = await account.create( ID.unique(), email, password, username );

TypeScript
if (!newAccount) throw Error;

const avatarUrl = avatars.getInitials(username);

await databases.createDocument(
  config.databaseId,
  config.userCollectionId,
  ID.unique(),

  {
    accountId: newAccount.$id,
    email: email,
    username: username,
    avatar: avatarUrl,
  }
);

await signIn({ email, password });
return { status: true };

} catch (error) { console.log(error); } };

export const signIn = async ({ email, password }) => { try { const session = await account.createEmailPasswordSession(email, password); if (!session) throw Error("Failed to create session");

TypeScript
return { status: true };

} catch (error) { throw Error(error); } };

export const getCurrentUser = async () => { try { const user = await account.get(); console.log(user.$id);

TypeScript
if (!user) return null;

const result = await getUser({ accountId: user.$id });

if (!result) return null;

return result;

} catch (error) { throw error; } };

export const getUser = async ({ accountId }) => { console.log(accountId);

try { const currentUser = await databases.listDocuments( config.databaseId, config.userCollectionId, [Query.equal("accountId", accountId)] );

TypeScript
if (!currentUser) return null;

return currentUser.documents[0];

} catch (error) { throw error; } };

NB : I have tried all the solutions outlined but no positive outcome.

TL;DR
Issue: User (role: guests) missing scope (account) error when trying to upload a profile photo using Appwrite and React Native. Solution: 1. Check if permissions are correctly handled in your dashboard and ensure the right permissions are assigned for the database collection. 2. Make sure to configure permissions properly. 3. Revisit the code to ensure all necessary permissions are in place. 4. Verify if the account has the correct permissions and scopes for the required action. Note: Despite trying the suggested solutions, the error persists, and no response has been received from the Appwrite support team.
៚მղოօl៚
8 Jan, 2025, 11:18

Check permission is correctly handled in your dashboard, you have given correct perms for the database collection

benedict_t
8 Jan, 2025, 11:30

I've done that already but still getting the error

៚მղოօl៚
8 Jan, 2025, 11:47

I get this error countless times, because I always forget to assign right perms to any/ miss to configure something. I too stuck with appwrite + react native, upload file to bucket for profile photo isn't working, and no one is replying to my support ticket.

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