Set Up API Credentials
Follow step-by-step instructions to set up a project and generate the required credentials.
We'll cover the following
There are a few steps that need to be completed before using the Map APIs. Depending on region, Google account type, or whether the Google Cloud Platform (GCP) has been used before, the workflow for setting up credentials may vary. The workflow outlined in this course is that of a first-time GCP user signing up with their personal Google account.
To generate an API key for the Google Maps API, begin by setting up a Google Maps project on the GCP. A Google Account is needed to access the GCP’sCloud console. Follow the steps given below to create a project on the GCP:
- Navigate to the GCP “Welcome” page using this link. A dialog box (often called a popup) appears. Accept the terms and conditions in the dialog box and proceed by clicking the “AGREE AND CONTINUE” button.
- In the navigation bar, click the “Select a project” dropdown option to the left of the search bar.
- Click the “NEW PROJECT” button in the top-right corner of the dialog box that appears.
- On the next page under “Project name,” enter a name that best describes the project. Under “Location” select “No organization.” Then, click the “CREATE” button.
- The GCP creates the project and returns to the “Welcome” page. Click the “SELECT PROJECT” button in the dialog box.
The slides below show the process.
Enable the project’s API
The Maps Embed API and Maps JavaScript API must be enabled for this project. Follow the steps below to enable the required Google Maps APIs for this project:
- Navigate to the library panel from the project dashboard. To do this, click the hamburger menu at the top left of the screen and open the sidebar menu. Then, move the pointer so that it hovers over the “APIs & Services” option. In the resulting menu, click the “Library” option.
- Click “VIEW ALL” under the “Maps” heading on the APIs library page.
- Search “Maps Embed API” and “Maps JavaScript API,” and open either one of them.
- Click the “Enable” button for the selected API to enable the API for the project. The site then redirects to the API overview page.
- In the menu for “Additional APIs,” search for the second API.
- Click the “Enable” button for the second API which enables the second API for this project. The site then returns to the API overview page.
Note: A pop-up may appear asking to enable billing. Cancel this pop-up for now. How to set up a billing account will be covered later in this course.
The slides below show the process.
Now that the project’s API is enabled, it’s time to complete the next step, which is creating an API key.
In this course, we’ll use the API key to make API requests that don’t require user authorization. User authorization only identifies the application. It isn’t needed to access public resources anonymously. For example, it isn’t necessary to retrieve information about a public YouTube video. To create an API key, follow the steps below:
- Find the credentials panel by clicking the hamburger menu on the top-left corner of the screen. This will open the sidebar menu.
- Hover over the “APIs & Services” option, and click the “Credentials” option from the resulting menu.
- Click “Create Credentials” to open the credentials dropdown menu.
- Select the “API key” option to create an API key. A dialog box opens with the API key.
- Click the copy icon in front of the API key to copy it. Use this key for the Google Maps applications in this course.
The slides below show the process.
Save the API key
Let’s save the API key that was just copied. Follow the steps below to do this:
- Click the “Edit” button in the widget below.
- Paste the API key into the “API_KEY” field.
- Click the “Save” button.
As soon as the value is saved, the platform replaces it in the widget below: