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
- Streamlit UI and local DB
I want to use Appwrite for automation, like run watchdog service every morning 3 am. Anyone got suggestions, already explored github and documentation no luck. ...
- [SDK] [Postman] Can't post to Users usin...
when trying to post to users I'm getting missing scopes and at the same time I'm getting an authorised scope How do I generate an API and get around this issue
- Auth broken after update from 1.8.0 to 1...
So ive been having issues creating, deleting or updating users on my appwrite instance after i updated from 1.8.0 to version 1.9.0. When trying to create a user...