MCPcopy Create free account
hub / github.com/modelcontextprotocol/go-sdk / TokenInfoFromContext

Function TokenInfoFromContext

auth/auth.go:55–61  ·  view source on GitHub ↗

TokenInfoFromContext returns the [TokenInfo] stored in ctx, or nil if none.

(ctx context.Context)

Source from the content-addressed store, hash-verified

53
54// TokenInfoFromContext returns the [TokenInfo] stored in ctx, or nil if none.
55func TokenInfoFromContext(ctx context.Context) *TokenInfo {
56 ti := ctx.Value(tokenInfoKey{})
57 if ti == nil {
58 return nil
59 }
60 return ti.(*TokenInfo)
61}
62
63// RequireBearerToken returns a piece of middleware that verifies a bearer token using the verifier.
64// If verification succeeds, the [TokenInfo] is added to the request's context and the request proceeds.

Callers 2

ServeHTTPMethod · 0.92
servePOSTMethod · 0.92

Calls 1

ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…