
How to add read permission for another user? I have tried to create read permission for me and another user and got an error

Can you provide a snippet of the code you're using to set the permissions?

You cant do that. You cant set permissions to other users through web sdk, only for your self. Only way to add permissions to other user is to use API-key, It means use appwrite functions or your own backend.

And what is the point to set permissions only to your self? There is no 'read' permission for all users on my collection and i want to give some of them permission to fetch this document

` const permissions = [Permission.write(Role.user(user.$id))]
if (chat.type === ChatType.Global)
permissions.push(Permission.read(Role.users()))
if (chat.type === ChatType.Private && friendId) {
permissions.push(Permission.read(Role.user(user.$id)))
permissions.push(Permission.read(Role.user(friendId)))
}
await databases.createDocument<MessageExternal>(
DATABASE_ID,
COLLECTION_ID_MESSAGES,
ID.unique(),
messageSent,
permissions
)`

I think for that first if statement you'd want Role.Any(). Not sure if that would be causing the issue though

https://appwrite.io/docs/references/cloud/client-web/databases
The web documentation says that you can create a document with permissions and update a documents permissions, so I'm not sure if the person who said you can only do this with the server sdk is right.

Everything is fine with first if, permissions in the second one causes an error

Do you need to push again the same permission you've already set outside of the if block?

err nevermind

I see ones read and ones write sorry

Are you getting that error when trying to set the permission or when trying to view that message?

Would you actually need to set the creator of the messages permissions, since the user signed in is who created the message I think they automatically get document permissions over that new item?

databases.createDocument is failing with error i attached before. Yes, i need to specify permissions. They are not created automatically

If you create a resource using a Client SDK without explicit permissions, the creator will be granted read, update, and delete permissions on that resource by default.

This is not a problem, i can not give permission for another user

If I'm not wrong, you can't give permission for another user client sided

you will need a function for that instead

Really? I was looking at the documentation and they have an example setting permissions on client side.
https://appwrite.io/docs/advanced/platform/permissions#:~:text=Example%20%231%20%2D%20Basic%20usage

But not for other user, only for user that is logged in. Then you can set permissions for anyone
Recommended threads
- Queries Length Error.
Hi All, I am having a issues across my app with how i am getting data, and just wanted to check if this was an issues with the new changes on appwrite over the...
- The current user is not authorized to pe...
I'm just getting this error while it was working couple minutes ago, my users have permissions to access and create tables data but on some databases I'm just g...
- My projects archived. Did not see the up...
Kindly restore project for me: 67680a26001bdf36beb8 You can delete: 678c96ba00305f78bb13 675d05040004853fb43f
