Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL Certification failure while calling Google Drive API using python #231

Open
AshuT930 opened this issue Dec 7, 2021 · 0 comments
Open

Comments

@AshuT930
Copy link

AshuT930 commented Dec 7, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant