Skip to content
Back

app.1232123@service.cloud.appwrite.io (role: applications) missing scope (account)

  • 0
  • REST API
jehlicot07
7 Jan, 2025, 21:40

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:

TypeScript
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

TypeScript
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

TypeScript
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!

TL;DR
Developers encountered an issue deleting a user session, receiving an error of missing scope (account). Solution is to use the Users class to delete a user's session. If using the Account class, ensure a user's session is set on the Appwrite client to act on their behalf.
Kenny
7 Jan, 2025, 21:54

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.

jehlicot07
7 Jan, 2025, 22:00

@Kenny, @Lacked Thanks i was able to resolved it with the users class

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