{
  "id": "go/grpc-permission-denied-token",
  "signature": "rpc error: code = PermissionDenied desc = missing or invalid authorization token",
  "signature_zh": "rpc 错误：code = PermissionDenied desc = 缺少或无效的授权令牌",
  "regex": "rpc\\ error:\\ code\\ =\\ PermissionDenied\\ desc\\ =\\ missing\\ or\\ invalid\\ authorization\\ token",
  "domain": "go",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The server's auth interceptor rejected the request because the metadata did not contain a valid bearer token, or the token was expired.",
  "root_cause_type": "generic",
  "root_cause_zh": "服务端的认证拦截器拒绝了请求，因为 metadata 中不含有效的 bearer 令牌，或令牌已过期。",
  "versions": [
    {
      "version": "1.45+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "An expired or malformed token is rejected deterministically on every attempt.",
      "fail_rate": 0.92,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Removes the security boundary entirely and lets unauthenticated clients reach protected handlers.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.92,
      "how": "md := metadata.Pairs(\"authorization\", \"Bearer \"+token)\nctx = metadata.NewOutgoingContext(ctx, md)\nresp, err := client.Get(ctx, req)\n// or as a unary interceptor:\nfunc auth(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, inv grpc.UnaryInvoker, opts ...grpc.CallOption) error {\n    ctx = metadata.AppendToOutgoingContext(ctx, \"authorization\", \"Bearer \"+getToken())\n    return inv(ctx, method, req, reply, cc, opts...)\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "type tokenAuth struct{ token string }\nfunc (t tokenAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) {\n    return map[string]string{\"authorization\": \"Bearer \" + t.token}, nil\n}\nfunc (t tokenAuth) RequireTransportSecurity() bool { return true }\nconn, _ := grpc.Dial(addr, grpc.WithPerRPCCredentials(tokenAuth{token: tok}))",
      "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": "2024-09-14",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}