#[SOVED] AppwriteException: User (role: guests) missing scope (account)

8 messages · Page 1 of 1 (latest)

bronze shadow
#

While creating a react-native application and using react-native-appwrite package, I encountered this error. Here is my code


client
    .setEndpoint(appwriteConfig.endpoint)
    .setProject(appwriteConfig.projectId)
    .setPlatform(appwriteConfig.platform);

const account = new Account(client);
const avatars = new Avatars(client);
const databases = new Databases(client);
const storage = new Storage(client);

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

        const currentUser = await databases.listDocuments(
            appwriteConfig.databaseId,
            appwriteConfig.userCollectionId,
            [Query.equal('accountId', user.$id)]
        );

        if (!currentUser) throw Error;

        return currentUser.documents[0];
    } catch (error) {
        console.log(error);
        throw new Error('Error getting current user');
    }
};```

I am getting error while calling this function as soon as my app starts to get any logged inuser.
tacit kite
#

If this failing after a user is logged in or before?

bronze shadow
#

after some painful hours of debugging found the bug it wasn't because of const user = await account.get(); as I previous thought, it was something else.

#

how to mark this solved?

#

[SOVED] AppwriteException: User (role: guests) missing scope (account)

tacit kite
#

Glad you were able to get that figured out!

wanton chasm
#

what was the solution you get ?