AppwriteException: user_unauthorized, The current user is not authorized to perform the request
- 0
- Databases
- Flutter
Hi guys,
I am trying to create a document with a logged in user in a flutter app. Unfortunately, I get the error:
AppwriteException: user_unauthorized, The current user is not authorized to perform the request (401)
The document security is actived.
I understand from other posts that you advice to use the dart SDK. If this is the workaround for the problem, I think this is not a good solution. I do not want to use one API key for all write requests of all users. Could you please help me?
here is the error
You need to add permissions for creating to the collection, I think.
I add them sending the userID of the user
You're doing this server sided, throught an appwrite function?
What do you mean by server sided? It is an Flutter mobile app.
Are you setting permissions for a different user, that is not the one using the app at such moment?
No, it is the same user
Okay, I double checked and seems that's because you don't have set write permission, in the collection level for that user
how do I do that? I defined Permission.write, see last screenshot
Why should I set collection level permission? I do not want that an user has access to a whole collection
that is why I set only document permissions
In the console, when you select the collection, you will need to set write for such user or users
In the section you see in this screenshot
So either I add all users or for every specific user that I want he has access to some document I need to define in the console?
to define him in the console
You can allow all users Create permissions. Then on Document creation, you can set the permissions for that Document (as you’re doing now)
Recommended threads
- Error With iOS Apps
I keep getting the below errors for my flutter app. The clients are registered and have been. This wasn't an issue a few hours ago. AppwriteException: AppwriteE...
- I'm getting an error on the console "j?....
On my self hosted instance version 1.8.1 the console is giving me this error when trying to view the rows for a table I recently created. My application is read...
- Websites hosted on my appwrite sites hav...
Hello, all my websites hosted on appwrite sites are not running I am getting this message "This site can’t be reached drivehub.appwrite.network took too long t...