0

I am trying to download files from shared with me in google drive. But unable to implement. When I download from my drive, its working fine. If you guys have any idea how to implement it, would help alot :)

Code:

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
import streamlit as st

gauth = GoogleAuth()
gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)

path = "/home/lungsang/Desktop/levelpack-UI/content/A0/1 docx-raw/"
folder = "1tuQxaiDOdbfv1JHXNAln2nbq1IvBOrmP"

file_list = drive.ListFile({'q': f"'{folder}' in parents and trashed=false"}).GetList()
if st.checkbox("Show file list?", True):
    for index, file in enumerate(file_list):
        st.write(index + 1, file['title'])
        file.GetContentFile(path + file['title'])

settings.yaml :

client_config_backend: settings
client_config:
  client_id: 556191342382-tbsh3m4jdh21j2jlnjarchkufljbsoec.apps.googleusercontent.com
  client_secret: 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

save_credentials: True
save_credentials_backend: file
save_credentials_file: credentials.json

get_refresh_token: True

oauth_scope:
  - https://www.googleapis.com/auth/drive.file
  - https://www.googleapis.com/auth/drive.install
  - https://www.googleapis.com/auth/drive
  - https://www.googleapis.com/auth/drive.metadata
lungsang
  • 133
  • 13
  • Do you have an error message? Define "cant download" also define "folder ID from shared with me" – Linda Lawton - DaImTo Sep 21 '22 at 11:18
  • @DalmTo, no error message. The program run without any error and without downloading files. – lungsang Sep 21 '22 at 11:21
  • well your doing a file.list thats not going to download anything anyway. Where's your file.get or your file.export code [manage-downloads](https://developers.google.com/drive/api/guides/manage-downloads) – Linda Lawton - DaImTo Sep 21 '22 at 11:25
  • In google drive, there is 'my drive' and 'shared with me' from where you can download files. So when i download from 'my drive' its downloading fine but not from 'shared with me' – lungsang Sep 21 '22 at 11:25
  • I still cant see your file download code. Shared with me is a folder you cant download a folder. Where is your code where you are downloading a file from within the share with me folder. Please edit your question and include [example] so that i can test it. There isnt enough code here to reproduce the issue you are stating. – Linda Lawton - DaImTo Sep 21 '22 at 11:51
  • Does this answer your question? [Downloading files from public Google Drive in python: scoping issues?](https://stackoverflow.com/questions/71343002/downloading-files-from-public-google-drive-in-python-scoping-issues) – Kris Sep 21 '22 at 13:10
  • What type of files are within that folder? – Daniel Sep 21 '22 at 22:11
  • @DalmTo, i have updated the code. When you run 'streamlit run *.py' it will start downloading files. If there is folder in folder, it wont download but if there is files in folder and give the folder id to code, it will download. Its working for me. not from 'shared with me' unfortunately. – lungsang Sep 22 '22 at 05:16
  • @Daniel, Tibetan langugage – lungsang Sep 22 '22 at 05:16
  • Thank you @Kris, the issue is not exactly what i am facing . – lungsang Sep 22 '22 at 05:21

0 Answers0