logo

Setting Up Google Sheets API

Before you can read or write to Google Sheets with Python, you need to set up access. It's a bit like getting a special keycard for your script.

Here is the high-level process:

  1. Go to the Google Cloud Console.
  2. Create a new project.
  3. Enable the "Google Sheets API" and "Google Drive API".
  4. Create a Service Account. This is like a "robot user" that will do the work.
  5. Download the JSON key file. Keep this safe! It contains the password for your robot.

Once you have your JSON key (let's call it credentials.json), you also need to share your actual Google Sheet with the "client email" found inside that JSON file, just like you'd share it with a human friend.

Now you are ready to write some code!

I walk through every click of this setup process in my Full Stack Google Sheets course.