[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
- MFA TOTP State Inconsistency After Disab...
MFA TOTP State Inconsistency After Disable/Re-enable Flow — Invalid Token During Verification Environment: - Next.js - node-appwrite - Session-based authentica...
- Terraform tablesdb_column type inconsist...
Hi, I am trying out the new terraform provider for appwrite that was introduced a few weeks back. As a first step I wanted to import our existing databases into...
- Payment problems
Its really beginning to frustrate me, last month I was on Pro plan on Appwrite cloud, I chose the option to downgrade next month(this one) to Free plan, and tha...