This commit is contained in:
iamqizhao
2015-07-22 19:24:44 -07:00
parent 3104ff998c
commit e1fea116b7

View File

@ -201,12 +201,12 @@ func NewServerTLSFromFile(certFile, keyFile string) (TransportAuthenticator, err
} }
// TokenSource supplies credentials from an oauth2.TokenSource. // TokenSource supplies credentials from an oauth2.TokenSource.
type tokenSource struct { type TokenSource struct {
oauth2.TokenSource oauth2.TokenSource
} }
// GetRequestMetadata gets the request metadata as a map from a TokenSource. // GetRequestMetadata gets the request metadata as a map from a TokenSource.
func (ts tokenSource) GetRequestMetadata(ctx context.Context) (map[string]string, error) { func (ts TokenSource) GetRequestMetadata(ctx context.Context) (map[string]string, error) {
token, err := ts.Token() token, err := ts.Token()
if err != nil { if err != nil {
return nil, err return nil, err
@ -221,7 +221,7 @@ func (ts tokenSource) GetRequestMetadata(ctx context.Context) (map[string]string
// if your program is running on a GCE instance. // if your program is running on a GCE instance.
// TODO(dsymonds): Deprecate and remove this. // TODO(dsymonds): Deprecate and remove this.
func NewComputeEngine() Credentials { func NewComputeEngine() Credentials {
return tokenSource{google.ComputeTokenSource("")} return TokenSource{google.ComputeTokenSource("")}
} }
// serviceAccount represents credentials via JWT signing key. // serviceAccount represents credentials via JWT signing key.
@ -266,5 +266,5 @@ func NewApplicationDefault(ctx context.Context, scope ...string) (Credentials, e
if err != nil { if err != nil {
return nil, err return nil, err
} }
return tokenSource{t}, nil return TokenSource{t}, nil
} }