GDrive: Problem with Shared Drive and Service Account

Thank you in advance for your time!

What is the problem you are having with rclone?

After 4+ hours of tinkering, I cannot for the life of me get my service accounts to access my shared drive. I have tried everything I could find on the internet (and it wasn't much). I'm sure it's a simple fix but I need a second pair of eyes.

I have tried it with a custom client id, without, and everything I can think of in-between.

What is your rclone version (output from rclone version)

rclone v1.51.0-353-g5f71d186-beta

I upgraded to the beta after a recommendation from a tutorial online, but I had the same behavior on the latest stable version.

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

Ubuntu Server 20.04 / 64 bit

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

Google Drive, Shared Drive

The command you were trying to run

rclone lsd shareddrive: --drive-service-account-file=/path/to/key/key.json --drive-impersonate user@email.com

My config:

type = drive
scope = drive
team_drive = XXX
client_id = XXXX
client_secret = XXXX
token = XXXX

Log of the command:

server:~$ rclone lsd teamdrive: --drive-service-account-file=/path/to/key.json --drive-impersonate user@email.com -vv
2020/05/20 16:28:06 DEBUG : rclone: Version "v1.51.0-353-g5f71d186-beta" starting with parameters ["rclone" "lsd" "teamdrive:" "--drive-service-account-file=/path/to/key.json" "--drive-impersonate" "user@email.com" "-vv"]
2020/05/20 16:28:06 DEBUG : Using config file from "/home/user/.config/rclone/rclone.conf"
2020/05/20 16:28:06 ERROR : : error listing: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?XXXXX": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."
}
2020/05/20 16:28:06 DEBUG : 4 go routines active
2020/05/20 16:28:06 Failed to lsd with 2 errors: last error was: couldn't list directory: Get "https://www.googleapis.com/drive/v3/files?XXXXX": oauth2: cannot fetch token: 401 Unauthorized
Response: {
  "error": "unauthorized_client",
  "error_description": "Client is unauthorized to retrieve access tokens using this method, or client not authorized for any of the scopes requested."
}

Any ideas?

Did you go through and give the service account the scope access?

https://rclone.org/drive/#2-allowing-api-access-to-example-com-google-drive

Sorry if that's something you did but that was my first thought from the error message.

Yes I did, and I just double-checked to be sure.