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:
"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.
You're using the clientSession Client object for the Teams call, not the client Client object.
Recommended threads
- I can't UNPAUSE my project with the free...
I received an email notifying me that my project had been paused due to inactivity, and the email included a link to "Restore project." However, that button red...
- How to bypass the rate limit on the back...
Once a month my app has a ton of usage and I always run into the Too many requests 429 error. I am trying to optimize the queues and jobs to manage that, but a...
- 401 - Project not accessible in this reg...
Hi Appwrite team, I’m experiencing a Cloud Console issue with my NYC region project. Problem: - Some Console pages return: “401 - Project is not accessible ...