MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / writeAuthError

Method writeAuthError

internal/agent/api.go:831–834  ·  view source on GitHub ↗

writeAuthError writes a 401 response with an RFC 6750 §3 WWW-Authenticate challenge. Every 401 on an endpoint that accepts Bearer auth MUST advertise the Bearer scheme so clients know how to retry (§3, first paragraph). When the failing credential WAS an OAuth bearer (sentinel err wrap or `ate2a_`

(w http.ResponseWriter, r *http.Request, err error)

Source from the content-addressed store, hash-verified

829// metadata document lands, add `resource_metadata="<url>"` here so MCP
830// clients can auto-discover the authorization server.
831func (a *API) writeAuthError(w http.ResponseWriter, r *http.Request, err error) {
832 w.Header().Set("WWW-Authenticate", a.authChallenge(r, err))
833 http.Error(w, "authentication required", http.StatusUnauthorized)
834}
835
836// authChallenge builds the RFC 6750 §3 WWW-Authenticate value for a 401 on a
837// Bearer-accepting endpoint, given the request and the auth error that caused

Callers 1

handleAgentIdentityMethod · 0.95

Calls 2

authChallengeMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected