From cf890d694e3b69e1a39f0e9c5a30000e1544f039 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Fri, 28 Aug 2015 17:32:25 -0700 Subject: [PATCH] rename audience --- credentials/credentials.go | 9 +++++---- credentials/oauth/oauth.go | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/credentials/credentials.go b/credentials/credentials.go index 10e56f157..4c1f04379 100644 --- a/credentials/credentials.go +++ b/credentials/credentials.go @@ -60,11 +60,12 @@ type Credentials interface { // GetRequestMetadata gets the current request metadata, refreshing // tokens if required. This should be called by the transport layer on // each request, and the data should be populated in headers or other - // context. When supported by the underlying implementation, ctx can - // be used for timeout and cancellation. + // context. uri is the URI of the entry point for the request. When + // supported by the underlying implementation, ctx can be used for + // timeout and cancellation. // TODO(zhaoq): Define the set of the qualified keys instead of leaving // it as an arbitrary string. - GetRequestMetadata(ctx context.Context, audience ...string) (map[string]string, error) + GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) // RequireTransportSecurity indicates whether the credentails requires // transport security. RequireTransportSecurity() bool @@ -140,7 +141,7 @@ func (c tlsCreds) Info() ProtocolInfo { // GetRequestMetadata returns nil, nil since TLS credentials does not have // metadata. -func (c *tlsCreds) GetRequestMetadata(ctx context.Context, audience ...string) (map[string]string, error) { +func (c *tlsCreds) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return nil, nil } diff --git a/credentials/oauth/oauth.go b/credentials/oauth/oauth.go index 9eff9c5b2..04943fdf0 100644 --- a/credentials/oauth/oauth.go +++ b/credentials/oauth/oauth.go @@ -51,7 +51,7 @@ type TokenSource struct { } // GetRequestMetadata gets the request metadata as a map from a TokenSource. -func (ts TokenSource) GetRequestMetadata(ctx context.Context, audience ...string) (map[string]string, error) { +func (ts TokenSource) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { token, err := ts.Token() if err != nil { return nil, err @@ -81,8 +81,8 @@ func NewJWTAccessFromKey(jsonKey []byte) (credentials.Credentials, error) { return jwtAccess{jsonKey}, nil } -func (j jwtAccess) GetRequestMetadata(ctx context.Context, audience ...string) (map[string]string, error) { - ts, err := google.JWTAccessTokenSourceFromJSON(j.jsonKey, audience[0]) +func (j jwtAccess) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { + ts, err := google.JWTAccessTokenSourceFromJSON(j.jsonKey, uri[0]) if err != nil { return nil, err } @@ -109,7 +109,7 @@ func NewOauthAccess(token *oauth2.Token) credentials.Credentials { return oauthAccess{token: *token} } -func (oa oauthAccess) GetRequestMetadata(ctx context.Context, audience ...string) (map[string]string, error) { +func (oa oauthAccess) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { return map[string]string{ "authorization": oa.token.TokenType + " " + oa.token.AccessToken, }, nil @@ -132,7 +132,7 @@ type serviceAccount struct { config *jwt.Config } -func (s serviceAccount) GetRequestMetadata(ctx context.Context, audience ...string) (map[string]string, error) { +func (s serviceAccount) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error) { token, err := s.config.TokenSource(ctx).Token() if err != nil { return nil, err