Back

AppwriteException: (role: applications) missing scope (account)

  • 0
  • Web
Alberto Abbate
15 Jul, 2024, 12:59

I'm trying to implement a simple login system in my application. I can create users and user sessions successfully, but when i try to delete either the current session or all sessions, or get a list of all sessions i get the above error. Here is the code I'm running:
// appwrite. config.ts import * as sdk from "node-appwrite"

const client = new sdk.Client(); client .setEndpoint(process.env.NEXT_PUBLIC_ENDPOINT!) .setProject(process.env.NEXT_PUBLIC_PROJECT_ID!) .setKey(process.env.NEXT_PUBLIC_API_KEY!);

export const databases = new sdk.Databases(client); export const storage = new sdk.Storage(client); export const messaging = new sdk.Messaging(client); export const account = new sdk.Account(client); export const users = new sdk.Users(client);

// Code that fails: try { const result = await account.createEmailPasswordSession( loginData.email, loginData.password, ); // session is created successfully if (result) { console.log("result", result) try { const list = await account.listSessions(); console.log(list) } catch (e: unknown) { if(e instanceof AppwriteException) { console.error(e); // AppwriteException: app.668e66460027825557a8@service.cloud.appwrite.io (role: applications) missing scope (account) // I get the same error from account.deleteSession("current") and account.deleteSessions() } } }

TL;DR
Developers are encountering an error when trying to delete or get a list of sessions in their application, specifically regarding missing scopes. The issue could be resolved by adding the necessary scope (account) to the role (applications) in the configuration settings.
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