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
- User (role: guests) missing scope (accou...
Hello! Probably it is something stupid but I can't figure it out. Read a ton of posts already and still need help. Self hosted Appwrite. Simplest login in web a...
- Different setJwt & setSession SDK
What is different setJwt & setSession when using SDK
- Invalid success param: URL host must be ...
Hi, i'm trying to do oauth with nextjs ssr: https://appwrite.io/docs/tutorials/nextjs-ssr-auth/step-7#oauth-server-action i'm using github codespaces for develo...