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
- Bug report: Race condition in Flutter SD...
Hi team, I've found an intermittent bug in the Flutter SDK (v20.3.0) when using `createOAuth2Session` on Android. **Symptoms** After `createOAuth2Session` re...
- New Build not visible on Domain
I pushed some new code to my Appwrite Site and the build succeeded and is shown as active. Yet, I can only see the new version of the site on Appwrite's provide...
- DNS bug
Hello, we found bug at the Appwrite Cloud Domains, when changing **only ** the Comment of CNAME, we get error DNS record already exists. Some DNS types do not ...