Creating Google Credentials¶
In order to be able to access the resources offered by Google APIs, we must first generate a file of credentials from a Google account.
In a few steps it is possible to get the json file that will be responsible for authenticating our account to Google services.
Creating a Google Cloud Platform project¶
First we need to create a project that will be used as a base to generate the credentials. It is in this project that we will define the APIs that we will use.
- Open the Google Cloud Platform with the Google account you want to use.
- At the top-left, click on Navigation menu > IAM & Admin > Create a Project.
Choose a Project Name and select the Location of your project. In the case of this plugin, an organization is not required.
If you don't see any organization when you click BROWSE, it's probably because you're using a personal account instead of a Google Workspace account. Some of the features described in Google Workspace developer documentation are only available to projects associated with an organization, so keep attention on this. For this plugin, the option of "No organization" can be used.
Click Create to complete this step.
Enabling the required APIs¶
With our project created, let's activate the APIs we want to use.
- At the top-left, click on Navigation menu > APIs & Services > Library.
In the search field, enter the name of the API (1) and press Enter.
- For Google Drive type
- For Google Sheets type
- For Gmail type
- For Google Cloud Vision type
Cloud Vision API
- For Google Calendar type
- For Google Drive type
In the search results list, select the API and click Enable
Creating OAuth Client ID Credentials¶
With the API activated, let's create the credentials that we will use to access the features through our application.
At the top-left, click on Navigation menu > APIs & Services > Credentials.
Click on + Create Credentials and select OAuth client ID.
In some cases, if you are creating credentials for the first time, you may see a message regarding the consent configuration.
In this case, you need to click Configure Consent Screen and follow these steps:
- In User Type, select Internal if you are using a Google Workspace account, External otherwise.
- On the OAuth consent screen tab you just need to fill in the required fields: App name, User support email and the Email address in the Developer contact information section.
- Click Save and Continue
- In the Scopes tab it is not necessary to change anything, just click on Save and Continue again.
- In the Test Users tab, if you are not using an organization and you selected the User Type as External in the first step, you will need to add the emails that will be allowed to use the credentials.
Just click on Add Users and add the email used to create the project. If you want, you can add and give permissions to other emails as well. At the end, click on Save and Continue.
If you selected Internal in User Type, you can skip the step above. Just click on Save and Continue.
On the Summary tab click on Back to Dashboard.
With the OAuth consent screen configured, back to APIs & Services > Credentials.
- Click on + Create Credentials and select OAuth client ID again.
- In Application type select Desktop app, choose a Name and click Create.
- After that, the credentials are ready to be used.
Downloading the OAuth credentials file¶
- Click on the option Download OAuth client, in the credential line that was created.
- Select Download JSON and save the file wherever you see fit. You can also rename the downloaded file.
- With the file in hand, just pass the path of this file when instantiating the plugin.
The first time you run a process using the credentials, a tab will open in the browser for you to authenticate your account. Just select the account used to create the credentials and allow access to the resources.
After that, a token file will be generated automatically, making it no longer necessary to repeat this login process.