User (role: guests) missing scope (account) after login; Self hosted; Auth

  • 0
  • Self Hosted
  • Auth
  • Web
18 May, 2024, 20:19

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 app. I am getting "User (role: guests) missing scope (account) after login" when I try to verify the login. Session for the user is being created correctly. Here is my route: ```"/auth/login", async (req, res) => { // Get the email and password from the request body let email =; let password = req.body.password;

try { const client = new Client() .setEndpoint(process.env.AWENDPOINT) .setProject(process.env.AWPROJECTID);

let account = new Account(client);
const session = await account.createEmailPasswordSession(email, password);

const awuser = await account.get(); // Here I am getting "User (role: guests) missing scope (account) after login"

res.status(200).json({ success: true });

} catch (error) { console.error("Login error:", error.message, error.stack); } ... rest of my code.```

console.log(session) is giving me the following:

  '$id': '66490a9639f94e3ba07e',
  '$createdAt': '2024-05-18T20:07:50.243+00:00',
  '$updatedAt': '2024-05-18T20:07:50.243+00:00',
  userId: '6648fa0200031ffaa264',
  expire: '2024-06-17T20:07:50.237+00:00',
  provider: 'email',
  providerUid: '',
  providerAccessToken: '',
  providerAccessTokenExpiry: '',
  providerRefreshToken: '',
  ip: '',
  osCode: '',
  osName: '',
  osVersion: '',
  clientType: 'library',
  clientCode: '',
  clientName: 'Node Fetch',
  clientVersion: '1.0',
  clientEngine: '',
  clientEngineVersion: '',
  deviceName: '',
  deviceBrand: '',
  deviceModel: '',
  countryCode: '--',
  countryName: 'Unknown',
  current: true,
  factors: [ 'password' ],
  secret: '',
  mfaUpdatedAt: ''
Developers are using server-side code with the web SDK which is causing the session to not persist. The error "User (role: guests) missing scope (account) after login" indicates an authentication issue. Ensure proper use of client-side vs server-side tools. Utilize 3 backticks for multi-line code. Check Appwrite documentation for authentication guidance.
18 May, 2024, 20:35

Btw, it's best to use 3 back ticks with multi-line code. See

18 May, 2024, 20:36

It looks like you're writing server code but you may be using the web sdk which is meant to be used client side. As such, the session is not persisting.

18 May, 2024, 20:36

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