
I try to get team of a user inside appwrite function, but i get this error:
AppwriteException: User (role: guests) missing scope (teams.read)
If i try on client side, it's working fine. I don't understand why.
There is my cloud function sample code
import { Client, Teams } from "node-appwrite";
//... inside function
const userJwt = req.headers["x-appwrite-user-jwt"];
const client = new Client()
.setEndpoint("https://cloud.appwrite.io/v1")
.setProject(process.env.APPWRITE_PROJECT_NAME)
.setSession(userJwt);
log('X')
const teams = new Teams(client);
log('Y')
const listTeam = await teams.list(); // <-- It's failed
log('Z') // <-- Didn't get this log

It's working on client side
import { Client, Teams } from "appwrite";
const client = new Client();
client
.setEndpoint("endpoint") // Your Appwrite Endpoint
.setProject("projectid"); // Your project ID
export const teams = new Teams(client);
const teamslist = await teams.list();
console.log(teamslist); // <-- get the team of the user

On appwrite function i try to get the team of the same user

@D5 there are here i have shared code that lead to auto block =/

role: guests
this means you're unauthenticated.
setSession(userJwt)
you shouldn't be passing the JWT to setSession()
. it should be setJWT()

Recommended threads
- Stuck at pinging the server to finish ad...
I'm not using the starter app and I'm not sure how to finish connecting my app to Appwrite.io. Is there a CURL command I can run to finish setup?
- 500 internal error
I get a 500 internal error when trying to access my database on appwrite cloud. Sometimes it would start working but this time it never corrects.
- Error getting session: AppwriteException...
I get this error `Error getting session: AppwriteException: User (role: guests) missing scope (account)` when running in prod. As soon as I try running my app o...
