You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to upload a docx file to google drive and I've already set up the client id for google drive API and downloaded the generated client_secrets.json file and added it in the same directory where my code is placed. My python code is as follows:
import os
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
gauth = GoogleAuth()
# Try to load saved client credentials
gauth.LoadCredentialsFile("mycreds.txt")
if gauth.credentials is None:
# Authenticate if they're not there
gauth.LocalWebserverAuth()
elif gauth.access_token_expired:
# Refresh them if expired
gauth.Refresh()
else:
# Initialize the saved creds
gauth.Authorize()
# Save the current credentials to a file
gauth.SaveCredentialsFile("mycreds.txt")
# gauth.LocalWebserverAuth()
drive = GoogleDrive(gauth)
test = 'demo.docx'
with open(test, "r", encoding="Latin-1") as file:
fn = os.path.basename(file.name)
file_drive = drive.CreateFile({'demo.docx': os.path.basename(file.name)})
file_drive.SetContentString(file.read())
file_drive.Upload()
print('File upload successful!')
for authentication when the code runs gauth.LocalWebserverAuth() it opens up google authentication page on the web browser. Once done it says, The authentication flow has completed. and returns back to code and throws an error.
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1129)
python-BaseException
The text was updated successfully, but these errors were encountered:
I want to upload a docx file to google drive and I've already set up the client id for google drive API and downloaded the generated client_secrets.json file and added it in the same directory where my code is placed. My python code is as follows:
for authentication when the code runs
gauth.LocalWebserverAuth()
it opens up google authentication page on the web browser. Once done it says,The authentication flow has completed.
and returns back to code and throws an error.The text was updated successfully, but these errors were encountered: