Google Drive API Integration Sample

Effortless Google Drive Connectivity: Python API Integration Demo


Discover Google Drive integration through this project. Utilize the example Python script to understand authentication and file upload to Google Drive. Acquire the necessary credentials by enabling the Google Drive API in the Google Cloud Console. This project provides a foundation for incorporating Google Drive functionality into your Python projects.

Code Link:


  1. Go to the Google console page:
    Go directly to the console page: Google Cloud Console page link
    Or go to the cloud page and press the console button.

  2. Create a new project:
    Select a new project option, and give it a name (an organization field is not compulsory).

  3. Go to the 3lines options icon at the top left of the screen and scroll until you find the IAM & Admin option, then select the Service Accounts option.

  4. At the Service Accounts Dashboard press the “ + Create service account” button.

  5. Give the new Service Account a name and a description (leave empty the other 2 optional steps) and press Done.

  6. The newly created service account will be displayed on the Service Accounts list, find the SA(service Account) that you created before, press the Three dots menu and select the “Manage Keys” option.

  7. Use the ADD KEY option to create a new key.

  8. Select the JSON option, and press Create.

  9. Then, open a new tab in your browser, open your Google Drive webpage and use the “+ New“ option to create a new folder.

  10. Now share the created folder with the “+ Share“ option.

  11. Go back to the Service Accounts dashboard and copy the SA “Email”.

  12. Then, continue on the Share window that is left open on Google Drive (to share our new folder) paste the SA email, give it the editor permission, and press share.

  13. Go back to the Google Cloud Console use the search tool (located at the top of the page) and search the Drive API.

  14. Select the Drive API from the search results.

  15. Then, enable the API.

  16. After that, open the project folder, move and rename as(service_account.json) the .json key download at the 8 Step, and install the requirements (We strongly recommend using a Python Virtual environment).
    the folder would look like the following picture:

  17. Open the file and replace the PARENT_FOLDER_ID value with your folder ID (to get this ID open the folder on Google Drive and copy it from the web URL).

    17.1. Copy from here:

    17.2. And paste it here:

  18. Finally, run the main Python script and check your Google Drive Folder (The new file should be there with the provided metadata in the Python code).

Gratitude Section

I would like to express my sincere gratitude for taking the time to thoroughly review this project. I hope you found it helpful, detailed, and easy to understand. My ultimate goal was to provide you with a comprehensive understanding of how the project works, and I hope that it has accomplished precisely that. Thank you for your time and effort.

Google Drive API Integration Sample
EQP Solutions, Esteban Quevedo January 24, 2024
Share this post
Bulls & Cows Game
A Java Gaming Experience