{
  "id": "go/grpc-permission-denied-auth",
  "signature": "rpc error: code = PermissionDenied desc = authentication failed: invalid token",
  "signature_zh": "rpc 错误：code = PermissionDenied desc = 认证失败：无效令牌",
  "regex": "rpc\\ error:\\ code\\ =\\ PermissionDenied\\ desc\\ =\\ authentication\\ failed:\\ invalid\\ token",
  "domain": "go",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The client provided an invalid or expired authentication token, or the server's authentication middleware rejected the credentials.",
  "root_cause_type": "generic",
  "root_cause_zh": "客户端提供了无效或过期的认证令牌，或者服务器的认证中间件拒绝了凭据。",
  "versions": [
    {
      "version": "1.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This is a security risk and not a proper fix; it may violate compliance requirements.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The token is invalid; retrying won't change the outcome.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "// Use a token source that refreshes automatically\nts := oauth.NewTokenSource(ctx, config)\ncreds := oauth.NewOauthAccess(token)\nconn, err := grpc.Dial(addr, grpc.WithPerRPCCredentials(creds))",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "// Server interceptor to validate token\nfunc authInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {\n    token, err := extractToken(ctx)\n    if err != nil || !validateToken(token) {\n        return nil, status.Errorf(codes.PermissionDenied, \"invalid token\")\n    }\n    return handler(ctx, req)\n}",
      "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.9,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-08-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}