Capture the actual HTTP response first
A login screen, SDK exception, and API gateway error can all describe different failures. Start with one failing request and record the method, host, path, status, response request ID, and the time it occurred. Do not copy an Authorization header, cookie, or full production response into a ticket. Confirm that the request reached the intended environment and endpoint before changing credentials.
If the client reports a network error without an HTTP status, investigate DNS, TLS, connectivity, or a browser policy such as CORS first. A 401 or 403 means some HTTP-speaking layer returned a response; it does not by itself prove which layer made the decision.
Use the status as a clue, not the whole diagnosis
| Response | What it generally means | First investigation |
|---|---|---|
| 401 Unauthorized | The request lacks valid authentication credentials. | Check whether credentials were sent, accepted, and intended for this API. Inspect a safe WWW-Authenticate challenge if present. |
| 403 Forbidden | The server understood the request but refused it; authenticating again usually does not fix a permission denial. | Check the account, role, resource, tenant, action, and policy involved. |
| 407 Proxy Authentication Required | A proxy requires authentication. | Check the configured proxy and its credentials rather than the API token. |
| 429 Too Many Requests | The service is limiting request volume. | Check rate limits and the documented retry guidance; do not treat it as an authentication failure. |
The HTTP standard defines the broad semantics, but an API may include more specific error codes in its body and may use a gateway that changes the response. Read the API’s own error documentation and correlate the response with server logs before deciding that a token or permission is wrong.
Reproduce the request without printing its secret
Use a disposable test account or a read-only endpoint when possible. Keep the token in an environment variable or approved secret manager, and ask curl to print only the status code while you compare the request method, URL, and non-sensitive headers with a known-good request.
: "${API_TOKEN:?Set API_TOKEN in environment}"
: "${API_BASE:?Set API_BASE in environment}"
curl --silent --show-error \
--output /dev/null \
--write-out 'HTTP %{http_code}\n' \
--header "Authorization: Bearer ${API_TOKEN}" \
"${API_BASE}/v1/profile"This example suppresses the response body and prints the HTTP status. It assumes the API uses bearer authentication; use the authentication scheme documented by your API. Avoid `curl -v` or trace output in shared logs because they can include request headers. Do not paste a live token into a public decoder or an online support form.
For 401, verify the credential and its intended audience
- Confirm the client actually sends the expected Authorization scheme and that an interceptor is not overwriting or dropping the header.
- Check whether the credential is expired, revoked, malformed, or loaded from the correct environment. A staging token sent to production may be syntactically valid but unusable there.
- For token systems that define issuer, audience, or scopes, compare those claims with the API’s documented requirements using approved internal tooling. Do not disclose the raw token while doing this.
- Inspect the documented WWW-Authenticate challenge and a sanitized API error code for the precise failure reason.
Do not refresh credentials in a tight retry loop. If the credential is valid but the API still responds with 401, use a request ID and timestamp to ask the API owner which authentication layer rejected it.
For 403, identify the missing permission boundary
A valid identity can still lack permission for one action or resource. Check the user or service account role, organization or tenant membership, resource ownership, endpoint policy, and whether the HTTP method is allowed. Compare a working request for the same identity and resource; change one permission-relevant variable at a time.
Some APIs report missing scopes as 403, while others use a different code. Follow the provider’s documented error contract rather than assuming every permission problem has the same response. Do not ask for a broader administrator token as the first fix; grant only the narrow permission required by the task.
Repeating an unchanged 403 request is not a repair. If the account should have access, provide the service owner with the sanitized request ID, identity type, target resource, action, and timestamp so they can inspect authorization logs.
Separate browser CORS failures from API authorization
A browser may block JavaScript from reading a response because the server did not allow the site’s origin or preflight request. This is a browser cross-origin policy failure, not proof that the API returned 401 or 403. Inspect the browser Network panel for the OPTIONS preflight and the actual request; compare that with a controlled non-browser request. Do not “fix” CORS by exposing credentials to every origin.
When a proxy, API gateway, and application all have authentication rules, use a request ID to determine which layer generated the status. This avoids changing application permissions when the request was rejected before it reached the application.
Close the incident with a repeatable check
Record the root cause, the least-privilege correction, and one safe test that proves the intended caller now succeeds while an unauthorized caller still fails. Add a regression test at the layer that owns the policy, and keep tokens, cookies, personal data, and unrestricted production payloads out of the test fixture.