Skip to content
Sites Hackathon is live / Aug 29 - Sep 12
Back

is it possible to make a document with permissions from Appwrite functions

  • 0
  • Databases
  • Functions
  • Flutter
dyslexic_daddy
27 Jan, 2025, 15:22
TypeScript
      databaseId: databaseId,
      collectionId: collectionId,
      documentId: userId,
      data: {
        'userId': userId,
        'email': userEmail,
        'createdAt': DateTime.now().toIso8601String(),
        'lastLogin': DateTime.now().toIso8601String(),
        'isActive': true,
      },
      permissions: [
        Permission.read(
            Role.user(userId)), // Only the user can read their document
        Permission.update(
            Role.user(userId)), // Only the user can update their document
        Permission.delete(
            Role.user(userId)), // Only the user can delete their document
      ],
    );

when i add the permissions in the functions i get an error AppwriteException: user_unauthorized, Permissions must be one of: (any, guests) (401 but when i remove it works fine ,i have selected all 10 of the Scopes for database.

TL;DR
Developers are trying to create a document with permissions using Appwrite functions, but are facing an `AppwriteException: user_unauthorized` error when setting permissions. The error is due to incorrect permissions being set up in the function, as permissions must be limited to `(any, guests)`. Removing the permissions resolves the issue.
Kenny
27 Jan, 2025, 15:33

How are you setting up your appwrite client?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more