diff --git a/option/option.go b/option/option.go index 74a2308..830c96d 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. @@ -84,7 +87,10 @@ func WithServiceAccountFile(filename string) 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} } // WithoutAuthentication returns a ClientOption that disables authentication.