Generating Google API keys

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.

  1. First, you will need to log into the Google Developers Console.
  2. Google Developers Console Projects

    Once on your Google Developers Console, create a new project. To do so, click the Create Project button on the top left.

  3. New Project details

    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.

  4. Project welcome screen

    It can take a few minutes to create the project for you. Once created, you will be taken to that project.

  5. Project APIs

    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.

  6. Project API Credentials

    Now, you’ll need to generate your API credentials. To do so, click on Credentials on the left side of the page.

  7. 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

    OAuth Client ID key generation

    To generate an OAuth Client ID, click on the button that says Create New Client ID. You will then be presented with a popup box that asks for the type of application, as well as authorized JavaScript origins and redirect URI.

    Application Types

    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.

    Authorized JavaScript origins

    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

    generate Public API Key

    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.

Was this article helpful? Join the conversation!