Registering Google API Keys¶
For the extension to work properly and avoid misuse of your API keys, you will have to register two keys and assign them to the correct TypoScript configuration properties:
- googleServerApiKey: A secret key used by PHP on the server.
The process to register the keys is the same for both, but each key needs different access privileges.
How to register the API keys¶
Go to the Credentials Console
Open a web browser and navigate to console.cloud.google.com/apis/credentials.
If you are not logged in, you will be asked to log into a Google Account. If you have multiple accounts, make sure that you log into the one with the billing information you would like to use.
The link above should bring you to the Credentials (1) section of the Google Cloud Platform’s APIs & Services console.
Ensure that you have selected the correct project from the drop-down menu (2) at the top of the page or created a new project.
Here’s how the console looks with some API keys already added (3):
Create new credential
Click the Create credentials button (1) and select API key (2) from the drop-down menu.
The new API credentials will be generated immediately and presented to you (1). You can copy the credentials right away by clicking the copy button (2).
Proceed by configuring the key
Click on the Restrict key button (3, above) to enter the Restrict and rename API key interface.
Give the key a name
Please note the warning (2) about the key being unrestricted. Never use an unrestricted key for public websites!
Configure access restrictions
Now, we need to restrict access to the key. We do this further down in the Restrict and rename API key interface. The two keys we are generating need different restrictions configured in the Access restrictions section.
- Select HTTP referrers (web sites).
- Click the Add an item button.
- Enter a domain pattern matching your website’s domain. If your web
site can be found at “https://www.dealersexample.com/”, the pattern
This key is used by the server (PHP script), so we can restrict it to the IP addresses used by the server.
Many cloud services use different inbound and outbound IP addresses. Make sure you use the outbound IPs.
- Select IP addresses (web servers, cron jobs, etc.).
- Click the Add an item button.
- Enter the IP address or IP address range in the address field.
Repeat step 2 and 3 until you have added all the necessary IP addresses.
If this is the first time you are using this project, you’ll have to enable the necessary APIs from the API library. If they are already enabled, you can skip to step 9.
These APIs are:
From within the Google Cloud Platform, select Library (1) from the left-hand navigation bar click this link to the API library
Use the search field (1) to search for the APIs.
Click on the correct API in the search result. You will be taken to the API’s detail page.
Click the Enable button to enable the API.
Repeat steps 2 through 4 until you have enabled all the necessary APIs.
When you are finished, navigate back to the Restrict and rename API key interface for the API key you’re working on.
Select APIs to use
Within the Restrict and rename API key interface, find your way to the API restrictions section.
- Select Restrict key.
- Click on the Select APIs drop-down menu.
- Tick the following checkboxes:
- Geocoding API
- Geolocation API
- Places API
- Click the OK button.
- Click the Save button.