Back

[SOLVED] AppwriteException: user_unauthorized, Permissions must be one of: (any, users, user:...

  • 0
  • Databases
  • Flutter
Mosh Ontong
2 Sep, 2023, 14:28

AppwriteException: user_unauthorized, Permissions must be one of: (any, users, user:64f30beb85479b9d1078, user:64f30beb85479b9d1078/unverified, users/unverified) (401)

TypeScript
 final clientProfileId = bookingTimeline.bookingRef.clientProfile.id;
    final ownerId = bookingTimeline.bookingRef.service.ownerId;

    // final uniqueRoles = {Role.user(clientProfileId), Role.user(ownerId)};
    final uniqueRoles = {Role.user(ownerId)};
    final permissions = [
      for (final role in uniqueRoles) ...[
        // Permission.read(role),
        Permission.update(role),
        Permission.delete(role),
      ]
    ];
TL;DR
The user is experiencing an "AppwriteException: user_unauthorized" error when trying to set permissions on a document. They initially set the permissions as "read(users)", "update(user:64f30beb85479b9d1078)", and "delete(user:64f30beb85479b9d1078)", but they want both the client and the owner of the service provider to have access. The error message suggests that the user does not have permissions to perform the action. The user discovers that the ownerId they are trying to add to the permissions is causing the error. The solution is to only add the current user
safwan
2 Sep, 2023, 14:29

The error message suggests that the user does not have permissions to perform the action.

Mosh Ontong
2 Sep, 2023, 14:31

actually it have

Mosh Ontong
2 Sep, 2023, 14:31
Mosh Ontong
2 Sep, 2023, 14:32

64f30beb85479b9d1078

is the current user so When I only add this to the permission it successfully created the document

Mosh Ontong
2 Sep, 2023, 14:34
TypeScript
/// the current user 
"read("user:64f30beb85479b9d1078")"
"update("user:64f30beb85479b9d1078")"
"delete("user:64f30beb85479b9d1078")"

/// the user owner of the service provider
"read("user:64ecc7a01620c0514f28")"
"update("user:64ecc7a01620c0514f28")"
"delete("user:64ecc7a01620c0514f28")"

but when this is the permission to be settled in during creating the document the error will be occured

Mosh Ontong
2 Sep, 2023, 14:37

It said that , Permissions must be one of: (any, users, user:64f30beb85479b9d1078, user:64f30beb85479b9d1078/unverified, users/unverified)

what I understand is that this user:64ecc7a01620c0514f28 is not allowed to be in the permission for updating, read, and deleting the document permission

Mosh Ontong
2 Sep, 2023, 14:39

That is why I set right now is

TypeScript
"read(users)"
"update("user:64f30beb85479b9d1078")"
"delete("user:64f30beb85479b9d1078")"

But what I want is this /// the current user "read("user:64f30beb85479b9d1078")" "update("user:64f30beb85479b9d1078")" "delete("user:64f30beb85479b9d1078")"

/// the user owner of the service provider "read("user:64ecc7a01620c0514f28")" "update("user:64ecc7a01620c0514f28")" "delete("user:64ecc7a01620c0514f28")"

because I want that both client and the owner of the service provider can read, update, and delete this document, not only the client can have this kind of access

safwan
2 Sep, 2023, 15:02

Are you setting these permissions from a client-side application?

Mosh Ontong
2 Sep, 2023, 19:03

yup

safwan
3 Sep, 2023, 05:04

I think that's the problem. When you are setting permissions on a document, it's best to do it from a server-sided environment.

Mosh Ontong
3 Sep, 2023, 07:34

ohh I seeee thanks safwan

safwan
3 Sep, 2023, 07:45

no worries! let me know if you need any help

safwan
4 Sep, 2023, 06:35

[SOLVED] AppwriteException: user_unauthorized, Permissions must be one of: (any, users, user:...

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