GET /api/v1/vault/passwords • HTTP 401 Unauthorized

HTTP 401 Unauthorized Error API Example — Request & Response Example

Demonstrates the standard response returned when a client attempts to access a protected resource without supplying an Authorization header.

1. HTTP Client Request (GET)

GET /api/v1/vault/passwords HTTP/1.1
{
  "Accept": "application/json"
}

2. Server JSON Response (HTTP 401 Unauthorized)

{
  "error": "Unauthorized",
  "code": "AUTH_TOKEN_MISSING",
  "message": "Authentication credentials were not provided. Include a valid Authorization Bearer token."
}

Copy-Paste Code Snippets (cURL, JavaScript Fetch, Python, Node.js)

curl -X GET "https://cometflow.space/api/v1/vault/passwords"
fetch('https://cometflow.space/api/v1/vault/passwords')
  .then(res => {
    if (res.status === 401) {
      console.log('Redirecting to login...');
    }
  });
import requests

res = requests.get('https://cometflow.space/api/v1/vault/passwords')
print(res.status_code) # 401

How This API Call Works Step-by-Step

  1. 1. Client calls protected endpoint without credentials.
  2. 2. Auth middleware checks req.headers.authorization and finds it undefined.
  3. 3. Server halts execution and sends 401 status.
  4. 4. WWW-Authenticate header informs client of required auth scheme.

Backend API Functions: The auth guard function returns res.status(401).json({ error: "Unauthorized" }) immediately.

Frequently Asked Questions

What is the difference between 401 Unauthorized and 403 Forbidden?

401 Unauthorized means "Who are you?" (you have not authenticated or your token is invalid). 403 Forbidden means "I know who you are, but you do not have permission to access this resource" (e.g. standard user trying to view admin page).