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
- One-time Cloud migration blocked by data...
Hi, I’m blocked on a one-time migration from Appwrite Cloud to my self-hosted Appwrite instance. We already fixed the region issue, and the migration now corre...
- [SOLVED] curl error Number: 6 — function...
Hello, I invested a lot of time in this error in a fresh install of appwrite 1.8.1 and lasted until fix, this if for helping anyone that can have the same weird...
- All My Project is Gone
Hello everyone, please help. Why have all my projects suddenly disappeared? I received a warning via email about one of my projects being paused. When I clicked...