Skip to content
Sites Hackathon is live / Aug 29 - Sep 12
Back

User (role: guests) missing scopes (["teams.read"])

  • 0
  • Flutter
  • Auth
  • Functions
  • Cloud
rlee128
2 Sep, 2025, 22:21

I keep getting this error: AppwriteException: User (role: guests) missing scopes (["teams.read"]) at new AppwriteException (/usr/local/server/src/function/node_modules/node-appwrite/dist/client.mjs:8:5) at <anonymous> (/usr/local/server/src/function/node_modules/node-appwrite/dist/client.mjs:294:17) at processTicksAndRejections (:12:39) Here is the scope for the function:

TypeScript
                "sessions.write",
                "users.read",
                "users.write",
                "teams.read",
                "teams.write",
                "databases.read",
                "tables.read",
                "collections.read",
                "columns.read",
                "attributes.read",
                "rows.read",
                "documents.read",
                "rows.write",
                "documents.write",
                "execution.write"
            ],```
Here is how I am calling teams:
```const client = new Client()
    .setEndpoint(Bun.env["APPWRITE_FUNCTION_API_ENDPOINT"]!)
    .setProject(Bun.env["APPWRITE_FUNCTION_PROJECT_ID"]!)
    .setKey(req.headers['x-appwrite-key'] ?? '');
  const tableDB = new TablesDB(client);
  const users = new Users(client);

const session = await users.createSession({
      userId: incomingData.user_id,
    });

const clientSession = new Client()
      .setEndpoint(Bun.env["APPWRITE_FUNCTION_API_ENDPOINT"]!)
      .setProject(Bun.env["APPWRITE_FUNCTION_PROJECT_ID"]!)
      .setSession(session.$id);

  console.log("Checking teams on: ", session.$id);
  

  const teams = new Teams(clientSession);

// Get all teams for the current user
    const teamsData = await teams.list();```

I do the same thing in another function with the same scope and access without an issue.
TL;DR
Developers are encountering a "User missing scopes" error while trying to call teams, likely due to using the wrong client object (clientSession instead of client). Make sure to use the correct Client object for the Teams call, as shown in the example.
ideclon
2 Sep, 2025, 22:56

You're using the clientSession Client object for the Teams call, not the client Client object.

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