Google Drive Service Account Blob


I have been using service account credentials with Google drive and rclone for some time. However it has gotten to the point where I need to dynamically pass the credentials in to some of our scripting for better security and flexibility. I have been attempting this for a few hours and not gotten anywhere trying to pass the json blob in to the command and it accept it always errors with this.
rclone lsd remote:path [flags]
Command lsd needs 1 arguments maximum: you provided 5 non flag arguments:

I am working in powershell core v6.1.1 on Windows.
I am testing on the latest beta build. rclone: Version “v1.47.0-002-gf5795db6-beta”

rclone lsd :drive:test --drive-team-drive=“driveID” --drive-client-id=“clientID” --drive-client-secret=“secret” --drive-scope=drive --drive-impersonate email@domain.notreal --fast-list --log-level DEBUG --log-file=.\test.log --drive-service-account-credentials=“json-blob”

What is the --drive-service-account-credentials expecting?
Secondly do you have any suggest passing this to rclone properly within powershell?



It is execting a single string with a JSON blob inside it.

That makes me think that there is a problem passing the string. It has " in it if I remember rightly. Not a powershell expert, but if this was bash I’d use the alternate delimiters ’ instead of " to fix that. A bit of googling leads be to believe that will work with powershell too.

You can also set an environment variable RCLONE_DRIVE_SERVICE_ACCOUNT_CREDENTIALS if that is easier.



It does work similarly in Powershell and it has the same result as using the " does with the rclone command however.

More analysis…
Sanitized version of what I am sending for the option.

“type”: “service_account”,
“project_id”: “projectID”,
“private_key_id”: “KeyID”,
“private_key”: “-----BEGIN PRIVATE KEY-----\nSOMERANDOMSTUFF\n-----END PRIVATE KEY-----\n”,
“client_email”: "",
“client_id”: “ClientID”,
“auth_uri”: “removedURL”,
“token_uri”: “removedURL”,
“auth_provider_x509_cert_url”: “removedURL”,
“client_x509_cert_url”: “removedURL”

The Error:
“Command lsd needs 1 arguments maximum: you provided 5 non flag arguments: [”:drive:test" “PRIVATE” “KEY-----\n”

I think the spaces within the the quoted values in the json blob is what rclone is having issues with now. It doesn’t have any issues with any of the content before that in the blob.



Strange… It is powershell doing the chunking into arguments and rclone is just reporting what it was given, so the solution to this lies within powershell somewhere!