To get credentials and activate Drive API, follow steps detailed in: https://developers.google.com/drive/api/v3/quickstart/python?authuser=3
Once your "client_secret_XXXXXXXXXXX.json" file is downloaded, rename it to "client_secret.json" and save it in project root folder.
Open a console and install modules using pip.
- Google-API-Python-Client Library:
pip install --upgrade google-api-python-client
- OAuth Library:
pip install --upgrade oauth2client
Finally, you can test your file using:
python img_uploader.py
localname = 'Pictures/foto1.jpg'
servername = 'sonarabsolute2018.jpg'
mimeType = 'image/jpeg'
If the uploading is OK it will be stored in URL_drive variable.
First time you run the script, your browser will open to approve permissions. It is only first time.