Getting Google API keys is quite an easy process. If you need to connect to services such as Google Drive or Google Maps from your website or another remote server, you will need a Google API key. The Google Developers Console can be used to obtain Google API keys with just a few simple steps.
First, you will need to log into the Google Developers Console.
Once on your Google Developers Console, create a new project. To do so, click the Create Project button on the top left.
Once the button is clicked, enter a project name. You may use the project ID that is already populated for you as this is simply a unique identifier used on Google’s end, or you can create your own. Then, click Create.
It can take a few minutes to create the project for you. Once created, you will be taken to that project.
From within your new project, click on APIs & auth. You should now see a list of services. Locate the API service that you want to use, and click on OFF to switch it to ON. That API service is now active on your account.
Now, you’ll need to generate your API credentials. To do so, click on Credentials on the left side of the page.
The information that you need to generate will vary depending on your application that uses the Google API. If you are using a service that will require user authentication such as uploading files to Google Drive, then you will need to create an OAuth Client ID. If you are creating an application that simply relays data from Google such as generating maps with Google Maps, then you will need a Public API Key.
Key generation for OAuth applications
Web application: This is an application that will be run within a web browser over a network such as a connection from a website.
Service account: This application type will allow your server to make a request to Google’s servers, but the response back will not require user consent. For more information on this type, take a look at Google’s documentation.
Installed application: This application type is used for an application that is physically installed onto a user’s hard drive and runs locally on their computer.
In this box, you will enter the location that your API calls are coming from. For example, you could enter https://example.com in this box. If you have additional domains that will be accessing the Google API, you may enter them on new lines.
Authorized redirect URI
In this field, you would define the exact url that will be used to process OAuth requests. For more information on this, take a look at Google’s Redirect URI documentation.
Public API key generation
To access services that do not require user authentication, such as Google Maps, you will need to use a public API key. To generate one, click on Create New Key. You will have a few different key options to generate:
Server key: Select this if you will be making API calls from a server.
Browser key: Select this option if you will be making API calls from the user’s browser.
Android key: If the user’s Android phone or tablet will be making the API call, use this option.
iOS key: This option is used for making API calls from an iPhone, iPad, or iPod.
Now that you have generated your Google API key or OAuth credentials, you will see them displayed in the Credentials page. You are now ready to use this information within your application.