-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
28 lines (23 loc) · 901 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from google.oauth2 import service_account
from googleapiclient.discovery import build
from googleapiclient.http import MediaIoBaseDownload
from googleapiclient.http import MediaFileUpload
import io
from googleapiclient.errors import HttpError
scope = ['https://www.googleapis.com/auth/drive']
service_account_json_key = 'google/credentials.json'
credentials = service_account.Credentials.from_service_account_file(
filename=service_account_json_key,
scopes=scope)
service = build("drive", "v3", credentials=credentials)
# Call the Drive v3 API
folder_id = "1LbfMFfpNnZvHFDVIRsnkXy9DOBeCsfwb"
query = f"'{folder_id}' in parents and trashed=false"
results = (
service.files()
.list(pageSize=10, fields="nextPageToken, files(id, name)", q=query)
.execute()
)
items = results.get("files", [])
for item in items:
print(item)