In this article I will explain step by step, how to get Google API Key (Client ID) and API Secret (Client Secret) from Google Developer Console.
In order to access Google APIs using OAUTH, we need to create a Project in Google Developer Console and generate the Google API Key (Client ID) and API Secret (Client Secret).
The generated API Key and API Secret will then be used for making OAUTH calls to the Google APIs.
Creating Project and Google API Client ID and Client Secret
In order to create Google API Client ID and Client Secret follow the below steps.
First you need to visit Google Developer Console using the following URL and Login with your Google account.
Submitting Personal and Payment Information
The very first process is to submit personal and payment information as the Google API Services are chargeable after the threshold limit.
Note: Without a Credit or Debit Card, you won’t be available to create Google API.
1. In the first step, select the Country and click on AGREE & CONTINUE.
2. In the next step, select Account type and fill the Payment method details and click on START FREE button.
3. Enter the CVV of your Credit or Debit card, and click on Continue button.
4. Then, again click on Continue button.
5. Next, enter the OTP received on your registered mobile number and click on SUBMIT.
6. Finally, once the payment is successful, you will now see the following screen where you can create an API.
Creating a API New Project
This process allows you to create a Google API project, you will need to follow the following steps.
1. In the Enabled APIs and services tab, click on CREATE PROJECT link.
2. Then, in the next step you will need to enter Project details such as the Project name TextBox and click on CREATE.
Enabling the APIs and the services
The following process is used to enable APIs in the project.
1. Let’s add API to the project by clicking the API library link as shown below.
2. Then, in the API library window, look for Google People API from the list and click on it.
3. Next in the Product details window, you need to click on ENABLE button.
4. The API is enabled now and you can proceed to create the Client ID and Client Secret.
Creating API Client ID and Client Secret
1. Now in the API/Service details window, click on CREATE CREDENTIALS button.
2. Then, in the Create credentials window, choose the API as People API and the User data RadioButton as Credential Type and click on NEXT.
3. In the next step, you can add scopes by clicking on ADD OR REMOVE SCOPES and click on SAVE AND CONTINUE button.
4. Next in the OAuth Client ID step, select Application type from autocomplete TextBox. Here it is Web application.
5. Then, specify a name to the OAuth2.0 client.
6. Next, you need to specify the Authorised redirect URIs of the application where the user will be redirected after successful authorization and click on CREATE.
7. Finally, the Client ID is successfully generated. Now, you have option to copy the Client ID or download the Client ID and Client Secret in JSON format.
Following is the downloaded JSON string which contains the Client ID and Client Secret along with other details.
{
"web": {
"client_id": "<Client_ID>",
"project_id": "<Project_ID>",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "<Client_Secret>",
"redirect_uris": [
"http://localhost:55989/CS.aspx","http://localhost:55989/"
]
}
}