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
- executeFunction intermittently throws Fo...
Environment: Flutter app using the Appwrite Flutter SDK, calling executeFunction for [describe endpoint, e.g. live-stream-related function]. *Description*: Int...
- HTTP Error 500 ''
Hello to everyone, I'm a Flutter developer and actually I'm developing an app using Appwrite.. during my tests and also massive ones I've noticed something we...
- How i can call increment with operators ...