Back

Getting 401 User Unauthorized when doing a getDocument

  • 0
  • Databases
  • Accounts
  • Web
Zeke(Jafesu)
31 Aug, 2023, 03:48

I have a Database and collection, that my web app is trying to query, and I am getting 401 unauth It was working before i upgraded to 1.4.0.

I verified the permissions on the collection, even added "Any" and "All Guest" and "All Users" (Even though my user is in a Team with full perms to the collection)

Logged out and back into the app, same thing. another collection is working fine, no idea why this isnt working.

TL;DR
The user is experiencing a 401 User Unauthorized error when trying to do a getDocument. Some suggestions for troubleshooting the issue are raised, including raising a bug report on GitHub, upgrading to version 1.4.1, and checking permissions on related collections. The user eventually discovers that the issue was due to not having set permissions on the related collection. The problem is resolved by setting the appropriate permissions.
Drake
31 Aug, 2023, 03:50

Any relationships in this collection?

Zeke(Jafesu)
31 Aug, 2023, 03:51

yes, oooh, check perms on the related collections?

Zeke(Jafesu)
31 Aug, 2023, 03:52

that was it. didn't even think to check relationships

Drake
31 Aug, 2023, 04:12

So the user didn't have access to the related document?

Zeke(Jafesu)
31 Aug, 2023, 04:48

yeah, i had created a new collection (related) and hadnt set permissions on that yet

Drake
31 Aug, 2023, 18:46

@Prateek Banga do you have some time to help with this? Should a user get a 401 if they don't have read access to a related document?

Prateek Banga
31 Aug, 2023, 20:05

Hmm, will have to see. I'll check this out tomorrow. The user should get document without the related document i think without read permission in related collection.

Prateek Banga
1 Sep, 2023, 11:48

@Zeke(Jafesu) can you try out upgrading to 1.4.1 and then try out your use case without having permission in related document. Technically, you should see the document without any related data if you don't have any permission for related collection.

I tried reproducing this in 1.4.1 and it's not a problem for me

Zeke(Jafesu)
1 Sep, 2023, 12:27

Yep. I'm on 1.4.1 I'll text this afternoon

Prateek Banga
1 Sep, 2023, 12:42

You can share the appwrite.json via appwrite-cli to help reproduce the bug. Use the Appwrite CLI: https://appwrite.io/docs/command-line-deployment#initializeProject

Zeke(Jafesu)
1 Sep, 2023, 13:06

Looks like the issue was resolved

Zeke(Jafesu)
1 Sep, 2023, 13:07

Not getting the error anymore

Prateek Banga
1 Sep, 2023, 13:50

great then, I'll mark this thread as SOLVED

Prateek Banga
1 Sep, 2023, 13:50

[SOLVED] Getting 401 User Unauthorized when doing a getDocument

Zeke(Jafesu)
1 Sep, 2023, 17:48

@Prateek Banga isn't fixed after all

Prateek Banga
1 Sep, 2023, 18:37
Prateek Banga
4 Sep, 2023, 07:35

Getting 401 User Unauthorized when doing a getDocument

Prateek Banga
8 Sep, 2023, 20:57

@Steven I was not able to reproduce this. If you get some time, please try to reproduce this.

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