Back

Cloud - USERS REST API - Unauthorized 401

  • 0
  • Web
Eilon
24 Feb, 2024, 15:41

Trying to get the User's info via rest api and by the userId from session. I'm getting ERR_ABORTED 401 (Unauthorized)

From the docs I read I need to send via a GET request those headers: GET /v1/users/{userId} HTTP/1.1 Host: HOSTNAME Content-Type: application/json X-Appwrite-Response-Format: 1.4.0 X-Appwrite-Project: 5df5acd0d48c2 X-Appwrite-Key: 919c2d18fb5d4...a2ae413da83346ad2

In my project's console I defined the hostname field as my local IP, it should be the same in the HOST Field ? What about the X-Appwrite-Key, from where do I get it ? Is this field optional ?

Thanks

TL;DR
Issue: Developers are receiving an "Unauthorized 401" error while trying to access User info via the REST API in a Cloud service. They are questioning whether the hostname should match their local IP in the 'HOST' field and are unsure about how to obtain the 'X-Appwrite-Key'. Solution: 1. Ensure that the 'HOST' field matches the correct hostname specified in the project's console. 2. Obtain the 'X-Appwrite-Key' from the Appwrite dashboard under API Keys. It is a required field for authorization and should be included in the request headers for successful access.
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