gRPC metadata

gRPC metadata is a collection of key-value pairs attached to an RPC separately from its protobuf message body. In this course, metadata carries authorization credentials and idempotency keys, providing functionality similar to HTTP headers.

Minimal example

go
md, ok := metadata.FromIncomingContext(ctx)
if !ok {
    return status.Error(codes.Unauthenticated, "missing metadata")
}
tokens := md.Get("authorization")

Learn this concept

Lesson 7.12 · Protobuf contracts in Go

Used in exercises

Exercise 7.13 · gRPC order service
Prerequisite conceptsgRPC