Google changed its API console user interface so this article is just an update of the screenshots of this post.
Create a Google service account
-
Login to your Google account.
-
Create a project here.
-
Populate the "Project name" and click "CREATE" button:
-
Wait until Google finished creating the project, you will be redirected to a new page (like the one shown below) once it is completed.
Under "Search for APIs & Sevices" field type "contacts" and click "Contacts API" search result:
-
You should be redirected to "Contacts API" page. Click the "ENABLE" button:
-
On "Contacts API" Overview page, click "CREATE CREDENTIALS" button at the right side:
-
You will be redirected to "Credentials" page. Select "Web server (e.g. node.js, Tomcat)" option from "Where will you be calling the API from?" field. Choose "Application data" from "What data will you be accessing?" field. Select "No, I’m not using them" option from "Are you planning to use this API with App Engine or Compute Engine?" field. Then click "What credentials do I need?" button:
-
Populate the "Service account name" field. Click the "Role" dropdown menu, from the selection choose "Project" then "Editor". Click "Continue" button:
-
You should be receiving a JSON file that contains private key of Google service account you've just created. Click "Ok" button of the popped alert box.
And you will be redirected to "Credentials" main page. Click the "Manage service accounts" link:
-
On "Service Accounts" page, click the "More actions" icon at the right of your Google service account and select "Edit" from the dropdown menu:
-
A window will pop up. Click the "SHOW DOMAIN-WIDE DELEGATION" to expand.
Tick the "Enable G Suite Domain-wide Delegation" checkbox, populate the "Product name for the consent screen" text field and click "SAVE" button:
Delegate domain-wide authority to Google service account
-
Login to your Google's suite or Google Apps with your account that has administrator role here.
-
Click "Security" from your "Admin Console" page:
-
You will be redirected to "Security" page, click "Advanced settings" to expand:
-
Still on "Security" page under "Advanced settings", click "Manage API client access" link:
-
You will be redirected to "Manage API client access" page. Open the JSON file that you received from creating your Google service account and copy the value of client_id:
-
Paste the client_id that you copied to "Client Name" field and populate the "One or More API Scopes" with "https://www.google.com/m8/feeds":
Note: If you want to add more API scopes check https://developers.google.com/identity/protocols/googlescopes.
-
Click the "Authorize" button:
Follow the instructions under "Google Contacts API PHP application" here.
Note: After testing creating contact, you need to "Refresh" your Google Contacts to show the newly created contact: