Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
neuron-whisperer opened this issue Oct 31, 2022 · 1 comment
Labels
question Further information is requested

Comments

@neuron-whisperer
Copy link

neuron-whisperer commented Oct 31, 2022

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:

  • The files do not appear anywhere in the Google Drive volume that is associated with my GCP account.
  • Google Drive won't separately allow me to login separately as the service account.
  • The Google Cloud Platform console has a wide variety of storage options - buckets, cloud volumes, etc. - but no option for an interface to Google Drive.

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?

@shcheklein shcheklein added the question Further information is requested label Nov 1, 2022
@kylefmohr
Copy link

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

  • Google Cloud Platform and Google Drive are almost entirely separated, so don't get hung up searching GCP for your files, they won't be there. The only thing I did in GCP was to create a Google Drive OAuth Client ID and Secret, for use in my settings.yaml file.
  • This is a good explainer on how to correctly create your client ID/secret: https://rclone.org/drive/#making-your-own-client-id
  • Once you have those, put them into settings.yaml like this:
# 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
from pydrive2.auth import GoogleAuth

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/, and try out the example script Upload-and-autoconvert-to-Google-Drive-Format-Example. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants