
What am I doing wrong?
I have a function that get trigger for every users.*.create
and it does the following:
Map<String, dynamic> functionData = jsonDecode(req.variables['APPWRITE_FUNCTION_EVENT_DATA']);
String userId = functionData["\$id"];
await database.createDocument(
databaseId: "---database id ---",
collectionId: "--- collection id ---",
documentId: userId,
permissions: [Permission.read(Role.user(userId))],
data: {
"code": "--- random code ---"
},
);
The document gets created successfully but client side
Client side i'm doing the following:
User user = await account.get();
Document document = await databases.getDocument(
databaseId: "---database id ---",
collectionId: "--- collection id ---",
documentId: user.$id,
);
Which throws:
AppwriteException: user_unauthorized, The current user is not authorized to perform the requested action. (401)
I am logged in as the user the triggered the function, so it should work or no?

Is document level security enabled on the collection?

Dang! No it wasnt, works now! <:appwritecheers:892495536823861258>

[SOLVED] AppwriteException: user_unauthorized
Recommended threads
- Hola equipo de soporte,
Hola equipo de soporte, Estoy desarrollando una Function en Appwrite Cloud con Node.js 22 y el siguiente package.json: { "name": "upload-whitelist", "type"...
- Sites 30MB limit from GitHub
I’m deploying a site from github as Other type on the Hobby plan. It is actually a Flutter web app but it’s in a subdirectory with the root being an html landin...
- Function running in cloud but not locall...
Hi everyone, I have an appwrite function which is on python3.12 runtime. I have a library (hnswlib) which builds wheels during installation. This works on appwr...
