From 3a1198cac5bf0b51e186acd7c280947744dd3062 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 22 Apr 2016 19:58:52 +0100 Subject: [PATCH] gcs: Don't configure the oauth token if service_account_file is supplied --- docs/content/googlecloudstorage.md | 19 ++++--------------- googlecloudstorage/googlecloudstorage.go | 3 +++ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/docs/content/googlecloudstorage.md b/docs/content/googlecloudstorage.md index c97c349f2..5c3d63c43 100644 --- a/docs/content/googlecloudstorage.md +++ b/docs/content/googlecloudstorage.md @@ -160,21 +160,10 @@ creating an account, a JSON file containing the Service Account's credentials will be downloaded onto your machines. These credentials are what rclone will use for authentication. -To use a Service Account instead of OAuth2 token flow, replace the -`token` section of your `.rclone.conf` with a `service_account_file` -pointing to the JSON credentials. - -For example, here's an example `.rclone.conf` that sets up read only -access using a service account: - -``` -[readonly-sync] -type = google cloud storage -project_number = 123456789 -service_account_file = $HOME/.rclone-service_account.json -object_acl = authenticatedRead -bucket_acl = authenticatedRead -``` +To use a Service Account instead of OAuth2 token flow, enter the path +to your Service Account credentials at the `service_account_file` +prompt and rclone won't use the browser based authentication +flow. ### Modified time ### diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go index c29f2e297..25ea96434 100644 --- a/googlecloudstorage/googlecloudstorage.go +++ b/googlecloudstorage/googlecloudstorage.go @@ -62,6 +62,9 @@ func init() { Description: "Google Cloud Storage (this is not Google Drive)", NewFs: NewFs, Config: func(name string) { + if fs.ConfigFile.MustValue(name, "service_account_file") != "" { + return + } err := oauthutil.Config("google cloud storage", name, storageConfig) if err != nil { log.Fatalf("Failed to configure token: %v", err)