This guide explains how to get started with any Google API, such as Google Maps, Google Calendar, Youtube, or Google Sheets. Google's APIs can allow your application to integrate with Google services on the web or in a native application. There are three types of credentials for Google APIs:

  • API Keys: These are standard keys sent with each request. You can restrict access to select HTTP referrers, IP addresses, or bundle identifiers for iOS and Android applications.
  • OAuth client: Used for requesting access to a user's Google account (such as for logging in).
  • Service Accounts: This type is for server-to-server interactions. It can also allow you to interact with all GSuite data for your account.

Overview

To get started, we'll work through the steps needed to retrieve your credentials. The process is as follows:

  1. Sign in to the Google Cloud Console.
  2. Create or Select an Organization and Project.
  3. Create Credentials for API access.
  4. Enable the APIs you plan to use. (Google Maps, Google Calendar, Youtube Data, etc.)

Step 1: Sign in to Google Cloud Console

To start, make sure you have an existing Google account and sign in to the Google Cloud console. This is where Google lets developers manage and monitor all its cloud services, including the Google Maps API.

Google Cloud Console Homepage

If this is your first time here, you may not see much on this page.

Step 2: Create or Select a Project

The next step is to create or select a project. If your account is attached to a company, you can also apply projects to an Organization. Select the "Select a project" button.

Select a project

Next, click Create Project or select an existing project from the list.

Create a new project

Enter a name for the project and assign it to an organization, or "No organization."

Project setup

With the new project in place, we are ready to create credentials for our apps to connect to the APIs.

Step 3: Create Credentials for API access

Before we can use an API, we need to create credentials, such as an API key, and associate it with the project.

Credentials menu

Make sure the project is shown at the top of the page. Then, open the side menu if it isn't already. From here, hover over the "APIs & Services" item, and then select "Credentials".

Create credentials button

From the Credentials screen, you can click "Create Credentials" to select the new credential type. The three available credential types are:

  • API Key
  • OAuth Client
  • Service Accounts

API Key

API key credentials are used for basic interactions with Google services that don't require user information. For example, the Google Maps API uses API keys for displaying maps, accessing route information, and creating custom maps on the Google maps platform. API keys are easy to use, as they are passed along with the request as a query string or authorization header.

To create an API key for your project, select it from the "Create Credentials" menu. A personalized key will be generated.

Key created modal

It is highly recommended that you select the "Restrict Key" link and configure access restrictions. From the "Restrict and rename API key" screen, you can limit the usage of the key by implementing a variety of application restrictions. For example, by choosing HTTP referrers you can choose which URLs can make calls to the API with this key.

Restrict key access settings

You can return to this screen at any time to modify these restrictions, regenerate or delete the API key, and see usage details.

OAuth Client

For applications that need access to a user's Google account, such as using Google's social sign-in, you will need to create an OAuth Client credential.

Set up OAuth client

Once you select OAuth Client from the "Create Credentials" button, you are asked to fill in an application type, name, and any authorized URIs for your application. Authorized origins are domains that can use these credentials. Authorized redirect URIs are where the user will be redirected after access has been granted. Make sure to enter any of the HTTP referrers web addresses you plan to use for your app.

Once finished, you'll be presented with your client ID and client secret. These are used for making OAuth requests, and required by many applications that integrate with Google APIs.

Before you can begin using this credential, you'll need to set up a consent screen and assign any scopes to the application. This is the screen users will see when they authorize access to your application. This is the place to include a link to your app, support email, and your application's logo. You'll also need to provide some additional information for Google to verify your application.

OAuth consent screen

You can find a full list of the available scopes for the Google Calendar API in the API documentation.

Service Account

Service accounts are used less often, but can be useful for server-to-server communication. Just as we did with the other credential types, select "Service account" from the "Create Credentials" menu.

Service account creation

Service accounts require an email address to use, and can automatically generate one for you. Creating a service account will also create a linked OAuth credential for use by the service account.

Retrieving your keys and secrets

If at any point you need to later access a credential API key or client secrets, you can do so from the "APIs & Services > Credentials" screen in the cloud console. For OAuth credentials, you can also download a JSON file containing the OAuth credentials for use within your application.

Activating Google APIs

With your application and credentials created, you can now active any API you like. From the sidebar, you can select "APIs & Services > Library" for a full list of available APIs. You can also use the top search to find a specific API, like the Google Maps Static API or Google Maps Javascript API. For example, we can search for Calendar:

API activation page

This page will also display and pricing information for paid APIs.

From here, select "ENABLE". The newly linked Google Calendar API will use any credentials you have created that are associated with it. You can also create new credentials directly from the "Credentials" link in the sidebar.

Each API dashboard provides an overview of the APIs usage stats, as well as links to documentation and getting started guides. You can also select the "Learn" button in the top right for further details on using the API.

API dashboard

For APIs that require a billing account, billing details will be provided on this dashboard.

What's Next?

Now that you know how to create an API key and set up credentials, you are all ready to begin building integrations with any of Google's web service APIs. View the full documentation and offerings at Google's Cloud Services page. You can also dive into popular products like: