Before you begin
Before you start using the Places SDK for iOS, you need a project with a billing account and the Places SDK for iOS enabled. To learn more, see Set up in Cloud Console.
Creating API keys
The API key is a unique identifier that authenticates requests associated with your project for usage and billing purposes. You must have at least one API key associated with your project.
To create an API key:
Console
-
Go to the Google Maps Platform > Credentials page.
-
On the Credentials page, click Create credentials > API key.
The API key created dialog displays your newly created API key. -
Click Close.
The new API key is listed on the Credentials page under API keys.
(Remember to restrict the API key before using it in production.)
Cloud SDK
gcloud alpha services api-keys create \ --project "PROJECT" \ --display-name "DISPLAY_NAME"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands:
Restricting API keys
Google strongly recommends that you restrict your API keys by limiting their usage to those only APIs needed for your application. Restricting API keys adds security to your application by protecting it from unwarranted requests. For more information, see API security best practices.
To restrict an API key:
Console
-
Go to the Google Maps Platform > Credentials page.
- Select the API key that you want to set a restriction on. The API key property page appears.
- Under Key restrictions, set the following restrictions:
- Application restrictions:
- Select iOS apps.
- To accept requests from the iOS app with the bundle identifier that you supply, select the appropriate iOS bundle identifier from the list.
- API restrictions:
- Click Restrict key.
- Select Places API from Select APIs dropdown. If the Places API is not listed, you need to enable it.
- To finalize your changes, click Save.
Cloud SDK
List existing keys.
gcloud services api-keys list --project="PROJECT"
Clear existing restrictions on existing key.
gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \ --clear-restrictions
Set new restrictions on existing key.
gcloud alpha services api-keys update "projects/PROJECT/keys/KEY_ID" \ --api-target="places-backend.googleapis.com" --allowed-bundle-ids="BUNDLE_NAME"
Read more about the Google Cloud SDK , Cloud SDK installation , and the following commands: