Project configuration in Google API Console – use of Google API Client Library for JavaScript – Part I. The ‘Google Workspace friendly application’ series.

11 December 2020 Wojciech Sowa

The ‘Google Workspace friendly application’ series – table of contents

  1. What is Google Workspace, and why should we integrate with it?
  2. Project configuration in Google API Console – use of Google API Client Library for JavaScript – Part I.
  3. Project configuration in Google API Console – use of Google API Client Library for JavaScript – Part II.
  4. Configuration of Oracle Database and APEX application – use of Google API Client Library for JavaScript.
  5. Project configuration in Google API Console – use of Google Service Account.
  6. Configuration of Oracle Database and APEX application – use of Google Service Account.

Introduction

In this article, I will present how to configure a project in Google API Console to use the vast possibilities offered by Google API. One of the necessary elements will be implementing the OAuth 2.0 protocol, through which we can call APIs accessing user’s private data. To implement OAuth 2.0, we will use the ‘Google API Client Library for JavaScript’ provided by Google. https://github.com/google/google-api-javascript-client.

This JavaScript library will be responsible for authenticating the user with his Google account. It will allow you to get the Access Token needed to call the API. You can use this token in calls from JavaScript and PL/SQL. We will also create an API key required for API calls that do not access the user’s private data.

Step by step guide

Go to https://console.developers.google.com/start – at this point, you can use the Google account in your organization’s domain to log in.

From the ‘APIs & Services’ menu, select ‘Dashboard’, and then select the available option ‘Create Project’.

If you already have any other project created in your account, its name will be visible instead.

Click on this, and in the pop-up window that opens, select the “New project” option in the top right corner.

On the new project configuration screen, enter its name and click the ‘Create’ button.

After creating the project, you will be automatically redirected to it. However, if this has not happened, select the newly created project from the project selector.

From the menu on the left side, go to the ‘Library’ tab. The entire library of available Google APIs appears. For our example, let’s say that we will need the ‘Google Drive API’ library. Find it and then choose it. On the summary screen, click the ‘Enable’ button.

After activating the API, you will be taken to the ‘Overview’ section, where there is information about it. You will find information about the usage statistics of this API over various periods and links to documentation and tutorials.

Select the ‘Credentials’ option from the menu available on the left, and then select the ‘+ Create Credentials’ option from the top bar. From the available menu, select the ‘OAuth client ID’ option.

In the first step of the wizard, you will be asked to configure the ‘Consent Screen’. This screen will appear every time you try to authenticate with Google, and it will contain a list of saved Google accounts with the option of selecting one to continue user activities. Select the ‘Configure Consent Screen’ button.

The wizard will ask you to select the type of user. We will focus on the ‘Internal’ type, limiting the possibility of integration to your organization. Click the Create button. 

On the ‘OAuth consent screen’, we have several attributes that you can adapt to your application’s needs. The mandatory fields are:

  • Application name
  • User support email
  • Email address in ‘Developer contact information’ section

Additionally, you can pick an image with the application logo or a link to the privacy policy. Click the ‘Save and Continue’ button.

In step 2, “Scopes”, you can select the scope of permissions for user data in Google Workspace that are applicable in your project. Using the “Add or remove scopes” option, select all relevant items from the list and click “Update”. Then click “Save and Continue”. You can learn about the scopes of permissions needed for your integration from the documentation for a specific Google API method.

In step number 3, “Summary”, you can see a summary of our Consent Screen. After verification, click the “Back to Dashboard” button.

In this stage, we are ending our configuration process. Stay tuned for the second part of this article!

Tagged with: , , , ,

Hire us!

Pretius is a software development company.
We create web applications using: Java, Oracle DB, Oracle Apex, AngularJS.
Contact us to talk about how we can help you with your software project!