Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
1.02k stars 136 forks source link

how to work with google drive shared drives #322

Closed omac777 closed 2 years ago

omac777 commented 2 years ago

Good day Mr. Byron,

I've attempted to use your drive3 tool, but with limited success.

I was given a google drive account, I have this email mercuryio@shadowmachine.com and a password for it.

I forced myself into google developer console, entirely separate product with the same email/password. I enabled google drive api. I created an oauth client token with type desktop application. I downloaded the .json secret file as instructed. I placed that .json file into the default drive3 configuration directory and renamed it to the required drive3-secret.json.

The only thing I have determined how to do successfully is the following to list the drives:

drive3 --scope=https://www.googleapis.com/auth/drive drives list
{
  "drives": [
    {
      "id": "0AK1EVy1amq0SUk9PVA",
      "kind": "drive#drive",
      "name": "CP_Mercury API Sync"
    }
  ],
  "kind": "drive#driveList"
}

I tried to do things like this but I was getting errors.

drive3 --scope=https://www.googleapis.com/auth/drive files copy mfwLogo16Mar2022.jpg
drive3 --scope=https://www.googleapis.com/auth/drive files list

Please if you could give me some steps to successfully copy/list a file in that said shared drive, it would be greatly appreciated.

Thank you in advance.

omac777 commented 2 years ago

I also noticed the google cloud sdk cli tools gcloud/gsutils use their own .json file which is incompatible with the rust google-drive3-cli .json secret file so the following command fails:

gcloud auth activate-service-account --key-file=/home/davidm/.google-service-cli/drive3-secret.json

It's funny because I logged into the gcloud auth login using the same email and password and attempted to list the shared drive there as well. The funny thing is I can't even list the shared drive "CP_Mercury API Sync" using google's official cli tools. I got further with your drive3 tool.

gcloud auth login mercuryio@shadowmachine.com
gcloud auth list
gcloud resource-manager folders describe 0AK1EVy1amq0SUk9PVA -p proj49708mfwtosm
gcloud config set project proj49708mfwtosm
gcloud asset list --project=proj49708mfwtosm
gcloud projects list --uri
gcloud services list --available
gcloud iam list-testable-permissions https://cloudresourcemanager.googleapis.com/v1/projects/proj49708mfwtosm --filter="customRolesSupportLevel!=NOT_SUPPORTED"

This is the one that disappoints me the most:

gcloud alpha storage ls
ERROR: (gcloud.alpha.storage.ls) One or more URLs matched no objects.

What are the drive3 equivalents of these? I can't get any of these to work with gsutil either. Any help with the gsutil cli tools would also be greatly appreciated as a stepping stone to figure out what's wrong with my drive3 cli usage:

gsutil ls -p proj49708mfwtosm gs://
gsutil ls -p proj49708mfwtosm gs://proj49708mfwtosm
gsutil ls -p proj49708mfwtosm 0AK1EVy1amq0SUk9PVA

Thank you again.