401 Decision Tree: Find Your Fix in Five Questions

401 Decision Tree: Find Your Fix in Five Questions

Lab-tested: Node 22.23.3 logic harness (lab) · 2 Dec 2026 · Every branch walked against real lab captures

Answer the questions above. The verdict will appear here with concrete next steps.

You need one captured response: run curl -si on your endpoint and look at the WWW-Authenticate header. Never test endpoints you do not own.

401 Decision Tree by 401.my.id.

Fix Box — Try This First (10 Seconds)

Capture one 401 response with curl -si and look at the WWW-Authenticate header. Then answer five questions in the tree below: challenge present, scheme, error code, expiry, header actually sent.

You get a verdict with concrete next steps and a link to the full guide. No account, no uploads; the tree runs entirely in your browser.

Why a Tree Beats Guessing

A 401 has at least eight distinct causes, and the fixes contradict each other. Refreshing helps an expired token and does nothing for a stripped header.

Re-entering a password helps a Basic failure and does nothing for insufficient scope. Guessing means applying fixes at random until one sticks, usually after hours.

The tree removes the guessing. Every question is answerable from one captured response plus one fact about your client.

The answers narrow to exactly one verdict. It is the same sequence we use in the lab before touching any configuration.

The Five Questions

Question one: does the response carry WWW-Authenticate? A 401 without a challenge usually comes from a WAF, CDN, or custom layer, not your app.

Question two: which scheme? Bearer and Basic cover most APIs; anything else goes to the Header Inspector.

For Bearer, question three reads the error parameter. invalid_request means malformed header.

insufficient_scope means re-authorize. invalid_token splits at question four: expired or not.

No error parameter at all leads to question five: did your client actually send the header? That last branch catches the proxy-stripping and redirect cases that waste the most time.

Eight Verdicts From Our Lab

We walked the tree against eight scenarios captured in our lab on 2 Dec 2026. A bare Bearer challenge with no header sent (our Nginx proxy-strip capture) lands on "Credentials never arrived".

An expired token capture lands on "Refresh the access token". A revoked token lands on "Token invalid or revoked". A scope capture lands on "Re-authorize with the missing scope".

The Basic branches mirror our nginx auth_basic captures: no credentials sent versus credentials rejected. The no-challenge branch covers the WAF-layer case from the pillar guide 401 Unauthorized: Causes and How to Fix It.

Every verdict links to the full guide for that cause, including OAuth refresh failures and Nginx 401s.

How the Tree Was Tested

The tree logic is a small JavaScript function with no dependencies. We tested it on our lab machine with Node 22.23.3: eight scenario walks, each asserting the expected verdict title and at least two concrete steps.

All eight passed, alongside the Header Inspector parser tests in the same harness (24 checks total, 0 failures). The full test output is stored with this package as lab evidence.

Honest lab note: the tree encodes the standard challenge semantics from RFC 9110 and RFC 6750. A vendor that returns non-standard challenges can still mislead it.

When the tree's verdict contradicts the response body, trust the body and inspect the raw headers with curl.

What Did Not Work

Our first draft asked "is the token expired?" before reading the error parameter. That misrouted invalid_request cases: a malformed header with an expired token got sent to the refresh branch, refreshed fine, and failed again on format.

Reading error first fixed the ordering. Format errors must be ruled out before token state.

We also tried auto-detecting everything from a pasted challenge alone. It failed on the missing-header branch: a bare challenge looks identical whether the client forgot the header or a proxy ate it.

One question about the client is unavoidable. The tree asks it instead of guessing.

FAQ

What do I need before starting the tree? One captured 401 response.

Run curl -si on your endpoint and find the WWW-Authenticate line. Everything else is answered from that capture.

The tree says credentials never arrived, but my code sends them. Now what? A layer between client and server is dropping the header: redirect, proxy, or framework config. Compare a direct request against a proxied one, as in our Nginx guide.

Does the tree store my answers? No. It runs in your browser with no backend calls. Nothing you click leaves the page.

My challenge has a scheme the tree does not list. Help? Paste it into the Header Inspector to break down every parameter, then read the scheme's RFC or vendor docs.

Can I use the tree for a 403? No, and you should not.

A 403 means credentials were accepted but lack permission. That is an authorization problem with different fixes.

Sources and Date

Lab tests run 2 Dec 2026 on Node 22.23.3 (logic harness, lab machine), against header captures from our Python mock API and nginx 1.26.3 labs the same day. Standards references verified live on 2 Dec 2026.

References