rlee128Original post
Rank 2: Process
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:
Plain text
"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.Summary
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.