{"record":{"id":"58e7364c349ae5d4","repo":"github/github-mcp-server","slug":"unauthorized","errorCode":null,"errorMessage":"Unauthorized","messagePattern":"Unauthorized","errorType":"http","errorClass":null,"httpStatus":401,"severity":"error","filePath":"pkg/http/middleware/token.go","lineNumber":55,"sourceCode":"\n\t\t\tctx = ghcontext.WithTokenInfo(ctx, &ghcontext.TokenInfo{\n\t\t\t\tToken:     token,\n\t\t\t\tTokenType: tokenType,\n\t\t\t})\n\t\t\tr = r.WithContext(ctx)\n\n\t\t\tnext.ServeHTTP(w, r)\n\t\t})\n\t}\n}\n\n// sendAuthChallenge sends a 401 Unauthorized response with WWW-Authenticate header\n// containing the OAuth protected resource metadata URL as per RFC 6750 and MCP spec.\nfunc sendAuthChallenge(w http.ResponseWriter, r *http.Request, oauthCfg *oauth.Config) {\n\tresourcePath := oauth.ResolveResourcePath(r, oauthCfg)\n\tresourceMetadataURL := oauth.BuildResourceMetadataURL(r, oauthCfg, resourcePath)\n\tw.Header().Set(\"WWW-Authenticate\", fmt.Sprintf(`Bearer resource_metadata=%q`, resourceMetadataURL))\n\thttp.Error(w, \"Unauthorized\", http.StatusUnauthorized)\n}\n","sourceCodeStart":37,"sourceCodeEnd":57,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/http/middleware/token.go#L37-L57","documentation":"Error \"Unauthorized\" thrown in github/github-mcp-server.","triggerScenarios":"Thrown at pkg/http/middleware/token.go:55 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}