from google.oauth2 import service_account
from googleapiclient.discovery import build
import io
from googleapiclient.http import MediaIoBaseDownload
SERVICE_ACCOUNT_FILE = './sec.json'
SCOPES = ['https://www.googleapis.com/auth/drive']
credentials = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
service = build('drive', 'v3', credentials=credentials)
# ID của thư mục bạn muốn tải file từ đó
folder_id = '14hPLOEFA2PPNZA2G3KpzKYc16FWZdVYS'
query = f"parents = '{folder_id}'"
results = service.files().list(q=query).execute()
print(results)
items = results.get('files')
download ....
my cred.json
{
"type": "service_account",
"project_id": "striking-splice-423903-a9",
"private_key_id": "",
"private_key": "",
"client_email": "[email protected]",
"client_id": "",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/tai-file%40striking-splice-423903-a9.iam.gserviceaccount.com",
"universe_domain": "googleapis.com"
}
the folder is shared to my email, not that client email, how to fix that
i am using gg drive api to download my files from a shared folder but the credentials.json file i created in google cloud iam is not my email, how can i fix that, i want the code to automaticly download and push to aws lambda. thanks
this is my code