[AppwriteException: User (role: guests) missing scope (account)]
- 0
- Databases
- React Native
- Apple
- Auth
I'm trying to make an app using expo and react-native. When I try to get the current user I get the error "[AppwriteException: User (role: guests) missing scope (account)]". I have narrowed it down to being in my getCurrentUser function when I do account.get(). Here is that function :
export const getCurrentUser = async () => {
try {
console.log("1")
const currentAccount = await account.get();
console.log("2")
if(!currentAccount) throw Error("No current account");
console.log(currentAccount)
const currentUser = await databases.listDocuments(
config.databaseId,
config.userCollectionId,
[Query.equal('accountId', currentAccount.$id)]
)
console.log(currentUser)
if(!currentUser) throw Error("No user found for current account");
return currentUser.documents[0];
} catch (error) {
console.log("error")
console.log(error)
}
}
And here are the logs I get when it runs so you can see that it errors on the account.get:
LOG 1
LOG error
LOG [AppwriteException: User (role: guests) missing scope (account)]
LOG NOT logged in current user
Here is where I call that funciton in my global context file:
useEffect(() => {
getCurrentUser()
.then((res) => {
if(res) {
console.log("logged in current user")
setIsLoggedIn(true);
setUser(res);
} else {
console.log("NOT logged in current user")
setIsLoggedIn(false);
setUser(null);
}
})
.catch((error) => {
console.log(error);
})
.finally(() => {
setisLoading(false);
}
);
}, []);
Sorry im new to react-native and appwrite so any help would be appreciated
Recommended threads
- Scheduled works locking the entire Maria...
I have a scheduled function and apparently that or something is locking the entire MariaDB database and Appwrite is giving MariaDB errors. This error persists e...
- Need help to create a wrapper which let ...
I’m looking for help setting up Appwrite properly on a VPS so I can build a self-hosting wrapper around it. The goal is to provide a Linux executable that allow...
- Apple OAuth2 "Registration Not Complete"...
I'm getting a "Registration Not Complete" error when implementing Apple Sign In OAuth2 on self-hosted Appwrite. Environment: Self-hosted Appwrite (latest), iOS...