I'm have a python script that gets data from a csv myFile.csv file and pushes it into a google drive folder.
When i run my code, I get an error
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/upload/drive/v3/files?fields=id&alt=json&uploadType=multipart returned "Insufficient Permission: Request had insufficient authentication scopes.". Details: "[{'domain': 'global', 'reason': 'insufficientPermissions', 'message': 'Insufficient Permission: Request had insufficient authentication scopes.'}]">
What I'm I missing?
Below is my code
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
import google.auth
scope = [
'https://www.googleapis.com/auth/drive.file',
'https://www.googleapis.com/auth/drive.resource',
'https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive',
'https://www.googleapis.com/auth/drive.readonly']
creds, _ = google.auth.default(scopes=scope)
def push_csv_to_google_drive(creds):
service = build('drive', 'v3', credentials=creds)
file_metadata = {"name": 'myFile.csv', "parents": [gdrive_destination_folder_id]}
media = MediaFileUpload(
source_csv_file_path,
mimetype="file/csv")
file = service.files().create(
body=file_metadata,
media_body=media,
fields="id").execute()
if __name__ == '__main__':
push_csv_to_google_drive(creds=creds)