While creating a react-native application and using react-native-appwrite package, I encountered this error. Here is my code
TypeScript
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.
TL;DR
Issue: Error "AppwriteException: User (role: guests) missing scope (account)" occurring in a React Native application using the `react-native-appwrite` package. The error happens when attempting to fetch the current user.
Solution: The error is due to missing permissions. Check if the user has the necessary scope 'account' assigned.If this failing after a user is logged in or before?
Recommended threads
- Use Limits
I need urgent help, i use appwrite as a chat function for my website and my mobile android application, but recently, for the past 3 months, my database reaches...
- redirect uri not working for OAuth with ...
I'm following this tutorial: https://appwrite.io/blog/post/google-oauth-expo#create-an-expo-app but im using an android development build instead. When I run h...
- Cannot use Apple Oauth2 in React Native/...
Hi! I've trying to add the Apple sign in feature into my Expo App. I followed the docs, but I still receiving the error "Cannot set 'location.href'". Can someon...