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
- Issue with relations on database
I'm creating a food ordering website for businesses. I'm having issues with the relations on my database I attached the attributes for the collections I'm hav...
- The current user is not authorized to pe...
I want to create a document associated with user after log in with OAuth. The user were logged in, but Appwrite said user is unauthorized. User is logged in wi...
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...