Web Developer
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()
}
}
}