Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

gcs: Don't configure the oauth token if service_account_file is supplied

Nick Craig-Wood3a1198cac5bf
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)