MCPcopy Index your code
hub / github.com/coder/coder / WriteOAuth2Error

Function WriteOAuth2Error

coderd/httpapi/httpapi.go:515–526  ·  view source on GitHub ↗

WriteOAuth2Error writes an OAuth2-compliant error response per RFC 6749. This should be used for all OAuth2 endpoints (/oauth2/*) to ensure compliance.

(ctx context.Context, rw http.ResponseWriter, status int, errorCode codersdk.OAuth2ErrorCode, description string)

Source from the content-addressed store, hash-verified

513// WriteOAuth2Error writes an OAuth2-compliant error response per RFC 6749.
514// This should be used for all OAuth2 endpoints (/oauth2/*) to ensure compliance.
515func WriteOAuth2Error(ctx context.Context, rw http.ResponseWriter, status int, errorCode codersdk.OAuth2ErrorCode, description string) {
516 // RFC 6749 §5.2: invalid_client SHOULD use 401 and MUST include a
517 // WWW-Authenticate response header.
518 if status == http.StatusUnauthorized && errorCode == codersdk.OAuth2ErrorCodeInvalidClient {
519 rw.Header().Set("WWW-Authenticate", `Basic realm="coder"`)
520 }
521
522 Write(ctx, rw, status, codersdk.OAuth2Error{
523 Error: errorCode,
524 ErrorDescription: description,
525 })
526}

Callers 6

writeMissingClientIDMethod · 0.92
writeInvalidClientIDMethod · 0.92
writeClientNotFoundMethod · 0.92
RevokeTokenFunction · 0.92
ProcessAuthorizeFunction · 0.92
TokensFunction · 0.92

Calls 3

WriteFunction · 0.85
SetMethod · 0.65
HeaderMethod · 0.45

Tested by

no test coverage detected