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
- 1:1 relationship doesn’t sync after re-a...
Hi, I’m trying to use a two-way one-to-one relationship. It works fine when I create a record with the relationship set, and it also works when I unset it. But ...
- Upsert with setting permissions
Hi there, I am using self-hosted appwrite v1.7.4 and trying to use the bulk update stuff that was released with 1.7.x. Unfortunally I found that there is an ser...
- One to many 2 way, console UI not correc...
Hey, seems I'm facing the exactly same issue with this one: https://github.com/appwrite/appwrite/issues/6016 Since this Github issue stay open for so long, let ...