diff --git a/option/option.go b/option/option.go index 74a2308..53ce66c 100644 --- a/option/option.go +++ b/option/option.go @@ -73,7 +73,10 @@ func WithAPIToken(token string) ClientOption { // WithServiceAccount returns a ClientOption that specifies the credentials file to use. func WithServiceAccount(data []byte) ClientOption { ts, sa, err := signer.NewServiceAccountTokenSource(data) - return withTokenSource{sa.ApiEndpoint, ts, err} + if err != nil { + return withTokenSource{"", nil, err} + } + return withTokenSource{sa.ApiEndpoint, ts, nil} } // WithServiceAccountFile returns a ClientOption that specifies the credentials file to use. @@ -82,9 +85,7 @@ func WithServiceAccountFile(filename string) ClientOption { if err != nil { return withTokenSource{"", nil, err} } - - ts, sa, err := signer.NewServiceAccountTokenSource(data) - return withTokenSource{sa.ApiEndpoint, ts, err} + return WithServiceAccount(data) } // WithoutAuthentication returns a ClientOption that disables authentication.