Reputation: 475
I am trying to save some .json
files to my google drive whenever I close my program. However, I receive this error:
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.">
I started with this module ~30 minutes ago and am working with what I found on the website, so it might be glaringly obvious, but here is my code:
SCOPES = 'https://www.googleapis.com/auth/drive'
store = file.Storage('credentials.json')
creds = None
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
drive_service = build('drive', 'v3', credentials=creds)
# updating function
async def googledriveupdate(file):
file_metadata = {'name': file}
media = MediaFileUpload('{}'.format(file),
mimetype='application/json')
file = drive_service.files().create(body=file_metadata,
media_body=media,
fields='id').execute()
print('File ID: ' + file.get('id'))
The idea is that whenever I close the program, this function will get called and all my files will be updated. However, I receive the 403 error and can't seem to fix it. Any idea what's happening here?
Upvotes: 2
Views: 2987
Reputation: 475
The issue was not my scope, however my pickle file.
If you also have this issue, try deleting your pickle file, and run the program again - this worked for me
Upvotes: 2