iterative / PyDrive2

Google Drive API Python wrapper library. Maintained fork of PyDrive.
https://docs.iterative.ai/PyDrive2
Other
571 stars 70 forks source link

How to view PyDrive2 files in Google Drive or Google Cloud Platform? #239

Open neuron-whisperer opened 1 year ago

neuron-whisperer commented 1 year ago

This is a really simple question. Not really a GitHub issue, but I have no idea where else to ask it.

I installed PyDrive2, created a project, created a service account, granted permissions, downloaded the permissions.json file, and cobbled together a basic Python script to store files on the account via PyDrive2. So far, so good.

The only problem is that I cannot, for the life of me, figure out how to view documents uploaded through PyDrive2 in either Google Drive or Google Cloud Platform. Things that I tried without success:

So, as it stands, I can't view PyDrive2-uploaded documents through any kind of file UI. It's like they just disappear into the cloud and are accessible only through PyDrive2.

Any suggestions?

kylefmohr commented 1 year ago

It's hard to know what's going wrong without seeing your code, but here's what I know:

# Original author: Evren Yurtesen - https://github.com/yurtesen/

client_config_backend: settings
client_config:
  client_id: <YOUR CLIENT ID GOES HERE>
  client_secret: <YOUR CLIENT SECRET GOES HERE>
  auth_uri: https://accounts.google.com/o/oauth2/auth
  token_uri: https://accounts.google.com/o/oauth2/token
  redirect_uri: urn:ietf:wg:oauth:2.0:oob
  revoke_uri:

save_credentials: True
save_credentials_backend: file
save_credentials_file: ./creds.json

get_refresh_token: True

oauth_scope:
  - https://www.googleapis.com/auth/drive.file

gauth = GoogleAuth()

Create local webserver and auto handles authentication.

gauth.LocalWebserverAuth()



Maybe you already had a valid auth token and the issue isn't that. Another thing to make sure of is that you're specifying the folder ID to upload the file to in Google Drive. To get your folder ID, navigate to the folder that you want the files in and copy the last part of the URL: https://drive.google.com/drive/u/1/folders/<YOUR FOLDER ID>, and try out the example script [Upload-and-autoconvert-to-Google-Drive-Format-Example](https://github.com/iterative/PyDrive2/blob/main/examples/Upload-and-autoconvert-to-Google-Drive-Format-Example/upload.py). You'll need to pass the folder ID as the first parameter, and the local path of the file to upload as the second parameter. 

If none of this helped, I'd need to see your code to help more.