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

Method GetRequestMetadata

credentials/oauth/oauth.go:159–176  ·  view source on GitHub ↗
(ctx context.Context, _ ...string)

Source from the content-addressed store, hash-verified

157}
158
159func (s *serviceAccount) GetRequestMetadata(ctx context.Context, _ ...string) (map[string]string, error) {
160 s.mu.Lock()
161 defer s.mu.Unlock()
162 if !s.t.Valid() {
163 var err error
164 s.t, err = s.config.TokenSource(ctx).Token()
165 if err != nil {
166 return nil, err
167 }
168 }
169 ri, _ := credentials.RequestInfoFromContext(ctx)
170 if err := credentials.CheckSecurityLevel(ri.AuthInfo, credentials.PrivacyAndIntegrity); err != nil {
171 return nil, fmt.Errorf("unable to transfer serviceAccount PerRPCCredentials: %v", err)
172 }
173 return map[string]string{
174 "authorization": s.t.Type() + " " + s.t.AccessToken,
175 }, nil
176}
177
178func (s *serviceAccount) RequireTransportSecurity() bool {
179 return true

Callers

nothing calls this directly

Calls 6

RequestInfoFromContextFunction · 0.92
CheckSecurityLevelFunction · 0.92
ErrorfMethod · 0.65
TypeMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected