{
  "id": "go/grpc-permission-denied-auth-missing",
  "signature": "rpc error: code = PermissionDenied desc = unauthenticated: request not authenticated",
  "signature_zh": "rpc错误：代码=权限被拒绝 描述=未认证：请求未通过身份验证",
  "regex": "rpc\\ error:\\ code\\ =\\ PermissionDenied\\ desc\\ =\\ unauthenticated:\\ request\\ not\\ authenticated",
  "domain": "go",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The gRPC call lacks required authentication credentials, such as a missing or invalid token.",
  "root_cause_type": "generic",
  "root_cause_zh": "gRPC调用缺少必需的身份验证凭据，例如令牌缺失或无效。",
  "versions": [
    {
      "version": "1.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "1.1",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Retry the request without adding any credentials.",
      "why_fails": "The server will continue to reject unauthenticated requests.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a hardcoded token that may be expired.",
      "why_fails": "Expired tokens are also rejected by the server.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Attach a valid authentication token to the gRPC metadata.",
      "success_rate": 0.9,
      "how": "token := \"valid-jwt-token\"\nconn, err := grpc.Dial(\"localhost:8080\", grpc.WithInsecure(), grpc.WithPerRPCCredentials(&authCreds{token: token}))\n// Define authCreds implementing credentials.PerRPCCredentials\nfunc (c *authCreds) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {\n    return map[string]string{\"authorization\": \"Bearer \" + c.token}, nil\n}\nfunc (c *authCreds) RequireTransportSecurity() bool { return false }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Implement an interceptor to add credentials automatically.",
      "success_rate": 0.85,
      "how": "func authInterceptor(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {\n    md := metadata.Pairs(\"authorization\", \"Bearer token\")\n    ctx = metadata.NewOutgoingContext(ctx, md)\n    return invoker(ctx, method, req, reply, cc, opts...)\n}\nconn, err := grpc.Dial(\"localhost:8080\", grpc.WithInsecure(), grpc.WithUnaryInterceptor(authInterceptor))",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}