Hi everyone,
I’m currently building an Express.js API to handle user account deletion, as I learned that the React Native SDK doesn’t support this functionality. Additionally, I want to integrate features like image compression and other processes through this external API.
However, I’m encountering an issue when trying to delete a user session. The error message I receive is:
app.[RANDOM_ID]@service.cloud.appwrite.io (role: applications) missing scope (account)
It seems like there’s a missing scope permission, but I’m not sure where or how to add the required scope. Below is the relevant code I’ve implemented so far. Any help or guidance would be greatly appreciated!
Appwrite.db.ts
import AppWrite, { Account, Databases, Messaging, Storage, Users } from "node-appwrite";
const client = new AppWrite.Client();
client
.setEndpoint(process.env.APPWRITE_API_ENDPOINT as string) // Your API Endpoint
.setProject(process.env.APPWRITE_PROJECT_ID as string) // Your project ID
.setKey(process.env.APPWRITE_API_KEY as string) // Your secret API key
.setSelfSigned(true); // Use only on dev mode with a self-signed SSL cert
export default {
client,
Auth: new Account(client),
Users: new Users(client),
Database: new Databases(client),
Storage: new Storage(client),
Messaging: new Messaging(client),
};
auth.services.ts
export const logout = async (sessionId: string) => {
try {
await AppwriteDb.Auth.deleteSession(sessionId);
const result: R<null> = {
code: StatusCodes.OK,
error: false,
message: "Logout successfully",
result: null,
};
return result;
} catch (err: any) {
return {
code: StatusCodes.INTERNAL_SERVER_ERROR,
error: true,
message: err.message,
result: null,
};
}
};
Does anyone know how to resolve this issue or properly set the account scope? Thanks in advance!
Use the users class to delete a users session. https://appwrite.io/docs/references/cloud/server-nodejs/users#deleteSession
If you want to use the account class you must have a users session set on the appwrite client to act on behalf of them.
@Kenny, @Lacked Thanks i was able to resolved it with the users class
Recommended threads
- context deadline exceeded
Hi, in one of my projects i continuously receive context deadline exceeded when trying to reach users API from my local machine: https://fra.cloud.appwrite.io/v...
- I am currently seeking opportunities as ...
Hey! 👋 I'm a Shopify guy. Been building stores for 8+ years. Still haven't lost my mind. Barely. I make stores that don't suck fast, smooth, and actually built...
- Mcp server offline?