MCPcopy
hub / github.com/grpc/grpc-go / GetRequestMetadata

Method GetRequestMetadata

credentials/oauth/oauth.go:41–53  ·  view source on GitHub ↗

GetRequestMetadata gets the request metadata as a map from a TokenSource.

(ctx context.Context, _ ...string)

Source from the content-addressed store, hash-verified

39
40// GetRequestMetadata gets the request metadata as a map from a TokenSource.
41func (ts TokenSource) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
42 token, err := ts.Token()
43 if err != nil {
44 return nil, err
45 }
46 ri, _ := credentials.RequestInfoFromContext(ctx)
47 if err = credentials.CheckSecurityLevel(ri.AuthInfo, credentials.PrivacyAndIntegrity); err != nil {
48 return nil, fmt.Errorf("unable to transfer TokenSource PerRPCCredentials: %v", err)
49 }
50 return map[string]string{
51 "authorization": token.Type() + " " + token.AccessToken,
52 }, nil
53}
54
55// RequireTransportSecurity indicates whether the credentials requires transport security.
56func (ts TokenSource) RequireTransportSecurity() bool {

Callers

nothing calls this directly

Calls 4

RequestInfoFromContextFunction · 0.92
CheckSecurityLevelFunction · 0.92
ErrorfMethod · 0.65
TypeMethod · 0.65

Tested by

no test coverage detected