{
  "id": "go/grpc-permission-denied-metadata",
  "signature": "rpc error: code = PermissionDenied desc = missing or invalid authorization metadata",
  "signature_zh": "rpc 错误：code = PermissionDenied desc = 缺少或无效的授权元数据",
  "regex": "rpc\\ error:\\ code\\ =\\ PermissionDenied\\ desc\\ =\\ missing\\ or\\ invalid\\ authorization\\ metadata",
  "domain": "go",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The server-side auth interceptor rejected the request because the authorization metadata (bearer token, API key) was missing or failed validation.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务器端认证拦截器拒绝了请求，因为授权元数据（bearer token、API key）缺失或验证失败。",
  "versions": [
    {
      "version": "google.golang.org/grpc v1.55+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "gRPC method names are fixed; query strings are not transmitted. Token never reaches the server.",
      "fail_rate": 0.98,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leaks the token into logs and business payloads; bypasses standard interceptor checks.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "md := metadata.Pairs(\"authorization\", \"Bearer \"+token)\nctx = metadata.NewOutgoingContext(ctx, md)\nresp, err := client.Get(ctx, req)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.93,
      "how": "func authUnary(token string) grpc.UnaryClientInterceptor {\n    return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, inv grpc.UnaryInvoker, opts ...grpc.CallOption) error {\n        ctx = metadata.AppendToOutgoingContext(ctx, \"authorization\", \"Bearer \"+token)\n        return inv(ctx, method, req, reply, cc, opts...)\n    }\n}\nconn, _ := grpc.NewClient(addr, grpc.WithUnaryInterceptor(authUnary(token)))",
      "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.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2025-01-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}