Every time you need a Google API key for different Google APIs. You need to create a new one for each different project. Follow these steps to get an API key.
Go to the Google Cloud Platform Dashboard.
Go to https://console.cloud.google.com/apis/dashboard to view your current applications registered in Google. If you have never created a project before, create a new project. For a new project, you need a Project Name (Example: MyApplication), and optionally, an organization. Google will give you a permanent application id associated to this project (Ex: myapplication-3563453).
Create or select a project
You can select a project from the list, or create a new one using the NEW PROJECT button. After selecting your project
Enable the Google APIs you need
Go to the Google API library to select a Google API to enable. For example, you can select the Google Maps API for iOS if you are working with iOS map applications. However, you can search for another API using the filters and the search box. Click on the “Maps SDK for iOS” or another API, and then enable it pressing the ENABLE button.
Create API Credentials
You need API credentials to access the Google services. After selecting the API and activating it, you can create credentials in the Credentials Tab. You can create 3 types of credentials:
- API key: Simple access using a single key. This key identify your project for access restrictions and quotas (number of requests to the API)
- OAuth Client ID: To enable user access using the Google Authentication interface and a Google Account, and to ask for user access permitions to private data.
- Service account key: Used for server-to-server communication to enable the use of an api internally by an application.
Note: If you already have a key with iOS/Android restrictions, you may use that key. You can use the same key with any of your Mobile applications within the same project.
When you create a new API key, you will get an API code to use in your application (Example: AIzbSyAkVPaziZAl_F5lPteYRQL3UyUnHjE7u50
). At this point, you may need to restrict your API key.
Restricting API keys for use in iOS applications
For iOS API keys, you may need to Restrict your API key, specially for Mobile applications in Android and iOS. Also, you may want to restrict your API key if you don’t want unexpected use of your API from external sources.
Restricting API keys for iOS applications
For an iOS application, you can use the following steps:
- From the dialog displaying the API key, select Restrict key to set an iOS restriction on the API key.
- In the Restrictions section, select iOS apps, then enter your app’s bundle identifier. For example:
com.example.hellomap
. - Click Save.Your new iOS-restricted API key appears in the list of API keys for your project.
For more information on using the Google Cloud Platform Console, see Google Cloud Platform Console Help.