Back

401 error in accounts.get() method

  • 0
  • Auth
  • Web
sajid_hussain.
24 Feb, 2024, 12:21

practicing the you tube video chai aur react series and encountered this error of unauthorization white getting the current account and I have make no mistake in syntax but I don't understand about this error checked all the imports and paths in to my react project all are correct but the result is an error

TL;DR
Developers encountered a 401 error in the `accounts.get()` method because the user was not authenticated. To resolve this, developers need to ensure the user is authenticated by calling `createEmailSession` with user credentials before accessing `account.get()`. The error is expected if no session exists.
Steven
24 Feb, 2024, 18:36

Yes, the error is expected if you don't have a session

Ankush Maurya
20 Mar, 2024, 08:50

How to solve this? I'm stuck here

Ernest
20 Mar, 2024, 17:58

There's nothing to solve getting that error simply means the user is not authenticated. When a user input their credentials during login, for example using email + password, you'd call the createEmailSession passing the credentials as arguments to create a session. Then return await this.acount.get(); will not throw errors. Check the docs:

https://appwrite.io/docs/products/auth/email-password

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