I'm struggling the get the current logged user using the method Account.get().
my code:
export async function getCurrentUser(){
try{
const currentUser = await account.get();
if(!currentUser) return null;
const user = await databases.listDocuments(
appwriteConfig.database,
appwriteConfig.usersDB,
[
Query.equal('accountId', currentUser.$id)
]
);
if(!user) throw Error("Usuario logado nao encontrado.");
return user.documents[0];
}catch(error){
console.log(error)
throw Error("Erro ao carregar o usuario logado.")
}
}
Its always returning the error:
code: 401,
type: 'general_unauthorized_scope',
response: {
message: 'User (role: guests) missing scope (account)',
code: 401,
type: 'general_unauthorized_scope',
version: '0.12.21'
}
How do I solve this?
Is this client-side code ? If yes, how have you instantiated the appwrite client ? Can you show please ?
Opps! I was running the code on server-side. Thats was the error. thanks for your help
[SOLVED] Error getting the current logged user
Recommended threads
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Streamlit UI and local DB
I want to use Appwrite for automation, like run watchdog service every morning 3 am. Anyone got suggestions, already explored github and documentation no luck. ...