
A Google Calendar API setup is the one-time work in Google Cloud that gives your app permission to read or create calendar events. You start with an empty Google Cloud account and finish with a downloaded credentials file that your code can load. Until that file exists, Google won't let your app touch a single calendar.
The setup has four parts: a project, the Calendar API, a consent screen and credentials. This guide covers them in order, explains why each one exists, and ends with a short Python test that confirms everything works. For normal use, none of it requires a paid plan.
- Create one Google Cloud project per app and check that it is selected before each step.
- Enable the Google Calendar API in that same project, because new projects start with every API off.
- Set up the OAuth consent screen, request the narrowest scope you need, and add yourself as a test user.
- Create a Desktop app OAuth client ID, save the file as credentials.json, and keep it out of Git.
- Run Google's Python quickstart. If your next events appear, the setup is correct.
- 0:00Intro
- 0:29Know the goal and gather your tools
- 1:18See how the pieces fit together
- 2:08Create a Google Cloud project
- 3:11Enable the Google Calendar API
- 4:12Configure the OAuth consent screen
- 5:15Choose the narrowest scope you need
- 6:15Add yourself as a test user
- 7:13Create an OAuth client ID
- 8:23Download your credentials JSON
- 9:19Guard your credentials like house keys
- 10:18Run a quick test script
- 11:21Fix the most common errors
- 12:08Level up your Calendar setup
- 13:16Four steps to a Calendar-ready app
- 13:45Four steps, and your app speaks Calendar
Map how your app gets permission to use Calendar
Before you click anything, it helps to know where you are heading. The goal is a Google Cloud project that is allowed to use the Calendar API, plus a credentials JSON file your code can use. For the setup you only need a Google account, either personal Gmail or Workspace, and a web browser. The test at the end uses Python 3 and a few terminal commands.
Every Calendar request passes through Google's permission system first. A user opens your app, and your app sends them to Google OAuth with your client ID. Google shows the consent screen. If the user agrees, Google returns an access token, and your app calls the Calendar API with that token. Your app never sees the user's password. It only receives the access the user chose to give.
Each piece you build has one job in that flow. The project is the box everything lives in. Enabling the API opens the door. The consent screen is the popup users see. The credentials are your app's ID badge.
- You have a Google account and can sign in to the Google Cloud Console
- Python 3 is installed if you want to run the final test
- The gcloud command-line tool is optional, because every step also works in the browser
- No credit card is needed. The Calendar API is free within its usage limits
Create a Google Cloud project for your app
A Google Cloud project is your app's home inside Google's building. Every API, setting and key you create will live inside it. You can create as many projects as you like. Keeping one project per app makes it obvious which settings and keys belong to which app.
Open console.cloud.google.com, click the project picker at the top, and choose New Project. Give it a clear name, such as my-calendar-app, and click Create. If you prefer the terminal, two gcloud commands create the project and set it as your default.
You can change the display name later. Google also assigns a project ID, and that ID is permanent and unique across all of Google Cloud. Choose something descriptive now so you don't have to hunt for a vague name later. The most common slip at this stage is working in the wrong project, so look at the top bar before every following step.
- The project has a descriptive name you will recognise later
- You have noted the project ID, since it cannot be changed
- The new project appears as selected in the console's top bar
# Console: project picker > New Project
# Or with the gcloud CLI:
gcloud projects create my-calendar-app
gcloud config set project my-calendar-app
Enable the Google Calendar API in that project
New projects start with their APIs switched off, so you turn on the Calendar API yourself. If you skip this step, every call your code makes will fail. You only do it once per project. It doesn't need repeating for each user or each version of your app, but it must happen in the same project that holds your credentials.
In the left menu, open APIs & Services, then Library. Search for Google Calendar API, open it, and click Enable. On the command line, the service is called calendar-json.googleapis.com.
APIs start switched off for a reason. Google Cloud offers hundreds of APIs, and turning on only the ones you need keeps your project tidy and its usage easy to track. It also limits what a leaked key could ever reach.
- The Enable button has changed to Manage
- A small usage dashboard for the Calendar API is visible
- You enabled the API in the project you will create credentials in
# Console: APIs & Services > Library
# Search 'Google Calendar API' > Enable
# Or with the gcloud CLI:
gcloud services enable \
calendar-json.googleapis.com
Configure the OAuth consent screen
With the API enabled, Google still needs to know who is asking for access. The OAuth consent screen is the popup that says your app wants access. When a user clicks sign in, your app redirects them to Google. Google shows your app's name, your contact email and exactly what you are requesting, and the user clicks Allow or Cancel.
In the console, open APIs & Services, then OAuth consent screen. In newer consoles, this page sits under Google Auth Platform as Branding. Enter an app name, a support email and a developer contact email, then save.
Next, pick a user type. Internal only works inside a single Google Workspace organisation. External allows any Google account, which is usually the right choice for a personal Gmail account or an app meant for outside users.
- An app name and support email are filled in
- A developer contact email is filled in
- The user type is set to External, or to Internal if you are inside a Workspace organisation
Pick the narrowest scope and add yourself as a tester
A scope is one specific permission, such as seeing events or changing them, and the consent popup lists each scope for the user. In the newer console this section is called Data Access. Click Add or remove scopes, search for Calendar, and tick only the scopes your features need. Fewer scopes look friendlier in the popup, so users are more likely to click Allow.
You will see three scopes most often. calendar.readonly lets your app view events but never change them, which suits a dashboard of today's meetings. calendar.events lets your app read and create events and is usually enough for booking meetings. Plain calendar is full access, including deleting calendars and changing sharing, and most apps rarely need it.
While your app is in testing mode, only listed test users can sign in. Open the Test users section, called Audience in newer consoles, click Add users, enter your email and save. You can list up to 100 testers. Add the exact account you will sign in with. If you list your Gmail address and then sign in with a work account, Google will block you.
- Only the Calendar scopes your features use are selected
- The full calendar scope is avoided unless a feature needs it
- Your exact sign-in account is on the test users list
# prefix: https://www.googleapis.com/auth/
calendar.readonly # view events only
calendar.events # view and edit events
calendar # full calendar access
Create an OAuth client ID and download the JSON
An OAuth client ID tells Google which app is asking, and it turns the consent screen into a real sign-in your code can use. Go to APIs & Services, then Credentials. In the newer layout, this page is called Clients and sits under Google Auth Platform. Click Create credentials and choose OAuth client ID. Don't choose API key, because an API key never asks a user for consent and so can't open anyone's private calendar.
For a script on your own computer, choose Desktop app. For a website, choose Web application and add your redirect URIs. Give the client a clear name and click Create. A dialog then shows your client ID.
Click Download JSON. The file contains a client ID, a client secret and redirect addresses. Desktop clients use the key installed, and web clients use the key web. Rename the long downloaded file to credentials.json and place it in your project folder, because that is the name Google's sample code looks for. Don't edit the file by hand. If you chose the wrong app type, create a new client and download a fresh file.
- The client type is Desktop app for local scripts
- The file is named credentials.json and sits in your project folder
- The file is unchanged from the download
{"installed": {
"client_id": "123...googleusercontent.com",
"client_secret": "GOCSPX-...",
"redirect_uris": ["http://localhost"]
}}
Keep credentials.json and token.json out of Git
Treat this file like your house keys. Anyone holding your client secret can pose as your app and use up your quota, and automated bots constantly scan public code for secrets. With your client details, someone could also build a fake sign-in that looks like your app and trick users into granting access. Your project's name and reputation would take the damage.
Before your first commit, add credentials.json and token.json to your .gitignore file. The token file appears after your first sign-in, so it is easy to forget. Then run git status and check that neither file is listed.
If a secret does leak, go to Credentials, reset the client secret or delete the client, download a new file, and update your app.
- credentials.json is listed in .gitignore
- token.json is listed in .gitignore
- git status shows neither file
# .gitignore
credentials.json
token.json
# check nothing slipped in:
git status
Run the Python quickstart to test your setup
Google's Python quickstart for the Calendar API checks everything at once: the project, the enabled API, the consent screen, your test user and the credentials file. If one piece is missing, you will find out here. First, install the client libraries with pip install google-api-python-client google-auth-oauthlib. Then copy the quickstart code from Google's Calendar API documentation and save it next to credentials.json.
Run python quickstart.py. A browser opens on Google sign-in, so choose your test account. An unverified-app warning is normal in testing mode, so click Continue. Approve read-only access. The script saves token.json and lists your next 10 events. If you see 'No upcoming events found', the setup still worked. Add a test event to your calendar to see it appear.
- The browser sign-in uses the account on your test users list
- token.json was created after you granted access
- Your upcoming events, or the 'No upcoming events found' message, appear
Fix common errors and prepare for launch
Most failures come from a few settings, and Google's error messages usually name the one that is wrong. Error 403: access_denied usually means your account isn't on the test users list. An API-not-enabled error means the Calendar API is off in the project your credentials belong to. Error 400: redirect_uri_mismatch points to the wrong client type or URI, and choosing Desktop app usually fixes it for local scripts. Insufficient permissions means your token has old scopes, so delete token.json and sign in again.
A FileNotFoundError usually means credentials.json isn't in the folder you run the script from. Check the file name too, since it can accidentally save as credentials.json.txt.
A few habits help as your app grows. In testing mode with external users, refresh tokens expire after 7 days, so if access stops after a week, delete the token and sign in again. Use separate projects for development and production, each with its own credentials. Before launch, publish the app and complete Google's verification for sensitive scopes.
- Start with readonly and add broader scopes only when a feature needs them
- Re-sign in if a testing-mode token stops working after 7 days
- Keep one project for experiments and another for real users
- Publish and complete verification before real users arrive
Key takeaways
- A Google Calendar API setup comes down to four parts: project, API, consent screen and credentials.
- Enable the Calendar API in the same project that owns your OAuth client.
- Request the narrowest scope that works, such as calendar.readonly or calendar.events.
- In testing mode, only listed test users can sign in, so add your exact account.
- Use an OAuth client ID rather than an API key, and keep credentials.json and token.json private.
- Google's Python quickstart is a quick way to confirm that every piece works together.
Frequently asked questions
Do I need a credit card to use the Google Calendar API?
Not for normal use. You can create a project and use the Calendar API without a paid plan, and the API is free within its usage limits.
Why does Google say access is blocked when I sign in to my own app?
This is usually Error 403: access_denied, and it means your account isn't on the test users list. Add the exact account you sign in with under Test users, which newer consoles call Audience, then try again.
Should I use an API key or an OAuth client ID for Google Calendar?
Use an OAuth client ID. An API key never asks the user for consent, so it can't open anyone's private calendar.
Which Calendar scope should I choose?
Use calendar.readonly if your app only displays schedules, and calendar.events if it creates or updates meetings. The full calendar scope also allows deleting calendars and changing sharing, so most apps don't need it.
Why did my Calendar script stop working after a week?
While an app with external users is in testing mode, refresh tokens expire after 7 days. Delete token.json and sign in again to get a new token.
Should I choose Internal or External on the consent screen?
Internal only works inside a single Google Workspace organisation. If you use a personal Gmail account, or your users come from outside your organisation, choose External.