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
- Function in Node.JS to monitor events ar...
Hello everyone. I'm creating my first Node.JS function, but I don't have much experience with node and javascript. I'm trying to create a function, that monito...
- Deploy function not working - 503
Hellon i get this error message, when i try to deploy a new version of a function <html><body><h1>503 Service Unavailable</h1>No server is available to handle...
- Error When load the website
Hi, I am getting this error whenever I reload my website please help me, I am using react Error: ** GET https://cloud.appwrite.io/v1/account 401 (Unauthoriz...