From a3bf6b9c2c7808c0434edb74be40623a805f2e67 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Sat, 28 Apr 2018 09:33:43 +0100 Subject: [PATCH] drive, gcs: fix service account authentication - fixes #2279 This fixes a problem introduced in b78af517de6720ea where it would attempt to read a non-existent service account file. --- backend/drive/drive.go | 4 ++-- backend/googlecloudstorage/googlecloudstorage.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backend/drive/drive.go b/backend/drive/drive.go index 5f733f9e3..14b24da27 100644 --- a/backend/drive/drive.go +++ b/backend/drive/drive.go @@ -464,8 +464,8 @@ func createOAuthClient(name string) (*http.Client, error) { // try loading service account credentials from env variable, then from a file serviceAccountCreds := []byte(config.FileGet(name, "service_account_credentials")) - if len(serviceAccountCreds) == 0 { - serviceAccountPath := config.FileGet(name, "service_account_file") + serviceAccountPath := config.FileGet(name, "service_account_file") + if len(serviceAccountCreds) == 0 && serviceAccountPath != "" { loadedCreds, err := ioutil.ReadFile(os.ExpandEnv(serviceAccountPath)) if err != nil { return nil, errors.Wrap(err, "error opening service account credentials file") diff --git a/backend/googlecloudstorage/googlecloudstorage.go b/backend/googlecloudstorage/googlecloudstorage.go index 0b77eb68b..c18cab6cb 100644 --- a/backend/googlecloudstorage/googlecloudstorage.go +++ b/backend/googlecloudstorage/googlecloudstorage.go @@ -293,8 +293,8 @@ func NewFs(name, root string) (fs.Fs, error) { // try loading service account credentials from env variable, then from a file serviceAccountCreds := []byte(config.FileGet(name, "service_account_credentials")) - if len(serviceAccountCreds) == 0 { - serviceAccountPath := config.FileGet(name, "service_account_file") + serviceAccountPath := config.FileGet(name, "service_account_file") + if len(serviceAccountCreds) == 0 && serviceAccountPath != "" { loadedCreds, err := ioutil.ReadFile(os.ExpandEnv(serviceAccountPath)) if err != nil { return nil, errors.Wrap(err, "error opening service account credentials file")