# rpc error: code = PermissionDenied desc = missing or invalid authorization metadata

- **ID:** `go/grpc-permission-denied-metadata`
- **Domain:** go
- **Category:** auth_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The server-side auth interceptor rejected the request because the authorization metadata (bearer token, API key) was missing or failed validation.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| google.golang.org/grpc v1.55+ | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   md := metadata.Pairs("authorization", "Bearer "+token)
ctx = metadata.NewOutgoingContext(ctx, md)
resp, err := client.Get(ctx, req)
   ```
2. **** (93% success)
   ```
   func authUnary(token string) grpc.UnaryClientInterceptor {
    return func(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, inv grpc.UnaryInvoker, opts ...grpc.CallOption) error {
        ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token)
        return inv(ctx, method, req, reply, cc, opts...)
    }
}
conn, _ := grpc.NewClient(addr, grpc.WithUnaryInterceptor(authUnary(token)))
   ```

## Dead Ends

- **** — gRPC method names are fixed; query strings are not transmitted. Token never reaches the server. (98% fail)
- **** — Leaks the token into logs and business payloads; bypasses standard interceptor checks. (85% fail)
