GetRequestMetadata gets the request metadata as a map from a TokenSource.
(ctx context.Context, _ ...string)
| 39 | |
| 40 | // GetRequestMetadata gets the request metadata as a map from a TokenSource. |
| 41 | func (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. |
| 56 | func (ts TokenSource) RequireTransportSecurity() bool { |
nothing calls this directly
no test coverage detected