Skip to content
Back

Error: User (role: guests) missing scope (account)

  • 1
  • Auth
  • Web
Lakshay Goyal
31 May, 2024, 12:59

// ============================== GET ACCOUNT export async function getAccount() { try { const currentAccount = await account.get(); console.log(currentAccount);

TypeScript
return currentAccount;

} catch (error) { console.log(error); // error here } }

// ============================== GET USER export async function getCurrentUser() { try { const currentAccount = await getAccount();

TypeScript
if (!currentAccount) throw Error;

const currentUser = await databases.listDocuments(
  config.databaseId!,
  config.userCollectionId!,
  [Query.equal("userId", currentAccount.$id)]
);

if (!currentUser) throw Error;

return currentUser.documents[0];

} catch (error) { console.log(error); return null; } }

TL;DR
Developers are encountering an error where users with the 'guest' role are missing the 'account' scope. The issue lies in the authentication process for retrieving user information. To resolve this, make sure that the 'account' scope is properly assigned to guest users to allow them access to account-related data.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more