Skip to content
Back

user_unauthorized for document creation

  • 0
  • Flutter
omar abdou
6 Apr, 2025, 19:39

Hello, whenever i want to create document from flutter i get user_unauthorized here are the steps i did

1 Register new user :

TypeScript
        userId: ID.unique(),
        email: email,
        password: password,
        name: name,
      );```

2 login :
```await account.createEmailPasswordSession(
        email: email,
        password: password,
      );```


3 creating the document :
```await databases.createDocument(
        databaseId: databaseId,
        collectionId: collectionId,
        documentId: ID.unique(),
        data: data,
      );```

Note: I selfhosted my instance

what im i doing wrong thanks ,
TL;DR
Issue: Getting 'user_unauthorized' error while trying to create a document from Flutter. Solution: Ensure the user's session is active by calling 'account.get' before creating the document. This might require re-authenticating the user to generate a new valid session. Steps taken: 1. Registered a new user using `account.create()`. 2. Logged in with the new user using `account.createEmailPasswordSession()`. 3. Attempted to create a document using `databases.createDocument()`, resulting in the error. Note: Since you are self-hosting the instance, verify that the authentication process is correctly implemented to
kamal.panara
6 Apr, 2025, 19:51

can you make sure that current user's session is still active by calling account.get before calling create document ?

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