go auth_error ai_generated true

rpc error: code = Unauthenticated desc = missing or invalid authentication token

ID: go/grpc-unauthenticated-metadata

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-09-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.x active

Root Cause

The gRPC request does not include the required authentication metadata (e.g., an authorization token) or the token is invalid.

generic

中文

gRPC 请求未包含所需的身份验证元数据(例如授权令牌),或者令牌无效。

Workarounds

  1. 95% success
    md := metadata.Pairs("authorization", "Bearer "+token); ctx := metadata.NewOutgoingContext(context.Background(), md); resp, err := client.Call(ctx, ...)
  2. 85% success
    Implement a token provider that obtains and caches valid tokens.

Dead Ends

Common approaches that don't work:

  1. 80% fail

    This weakens security and is not advisable in production.

  2. 90% fail

    The server will still reject it.