I'm trying to download a spreadsheet from my google drive. I'm following this reference and having problems with permission. I've started with https://www.googleapis.com/auth/drive.file and got this
"Insufficient Permission: Request had insufficient authentication scopes."
Reading through the permission documentation one reads the following for https://www.googleapis.com/auth/drive.
Full, permissive scope to access all of a user's files, excluding the Application Data folder.
but even using this scope I still got the same error message.
My code is this
import io
import pickle
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.http import MediaIoBaseDownload
file_id = "FILE ID"
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/drive']
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
service = build('drive', 'v3', credentials=creds)
request = service.files().export_media(fileId=file_id, mimeType='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
fh = io.BytesIO()
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print("Download %d%%." % int(status.progress() * 100))
token.pickle
and reauthenticate? – Rafa Guillermo