`drive-service-account-credentials` option not respected

What is the problem you are having with rclone?

I would like to store the service account credentials directly inside of my rclone.conf.

I am finding that:

  • rclone.conf does not respect drive-service-account-credentials option.
  • rclone.conf does respect the drive-service-account-file option.

The documentation seems to indicates that this should be possible:

If you'd rather stuff the contents of the credentials file into the rclone config file, you can set service_account_credentials with the actual contents of the file instead, or set the equivalent environment variable.

I've narrowed down my difficulties to this part of backend/drive/drive.go, but I am a bit lost on why I'm receiving an error.

I appreciate any help!

What is your rclone version (output from rclone version)

I am using the Docker image rclone/rclone:latest

rclone 1.53.3
- os/arch: linux/amd64
- go version: go1.15.5

Which OS you are using and how many bits (eg Windows 7, 64 bit)

I am using the Docker image rclone/rclone:latest on Docker Desktop for macOS

Which cloud storage system are you using? (eg Google Drive)

Google Drive

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone lsd gdrive:/

The rclone config contents with secrets removed.

[gdrive]
type = drive
scope = drive
drive-service-account-credentials = {"type":"service_account","project_id":"XXXX","private_key_id":"1a0470cc40a302ef24543XXXXXXXXXXXXXXXXXXX","private_key":"-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX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XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXn-----END PRIVATE KEY-----\n","client_email":"XXXXXXXXXXXXXXXX.iam.gserviceaccount.com","client_id":"107503369828885381109","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/XXXXXXXXXXXXXXXXXX.iam.gserviceaccount.com"}
team_drive = 0AJvml8rF5OZRXXXXXX

A log from the command with the -vv flag

# rclone lsd -vv gdrive:/
2020/12/05 09:14:54 DEBUG : rclone: Version "1.53.3" starting with parameters ["rclone" "lsd" "-vv" "gdrive:/"]
2020/12/05 09:14:54 DEBUG : Using config file from "/config/rclone/rclone.conf"
2020/12/05 09:14:54 DEBUG : Creating backend with remote "gdrive:/"
2020/12/05 09:14:54 Failed to create file system for "gdrive:/": drive: failed when making oauth client: failed to create oauth client: empty token found - please run "rclone config reconnect gdrive:"

That's because it's actually:

service_account_file =

and you put the path to the service account file location like /home/test/service.json

There is an option for specifying the credentials in the config file itself: https://rclone.org/drive/#drive-service-account-credentials

The config file option is service_account_credentials, not drive-service-account-credentials

1 Like

What does that do differently from using a service account file?

You can embed the contents of the service_account_file within the rclone config itself rather than using a separate file.

1 Like

My goodness! I totally did not notice that mistake, thank you very much @darthShadow :grinning_face_with_smiling_eyes:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.