[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
- Rate Limit of project
AppwriteException: Rate limit for the current endpoint has been exceeded. Please try again after some time. So , how much time I have to wait and why does it h...
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- apple exchange code to token
hello guys, im new here 🙂 I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...