In this article, I will tell you how to use Gmail API. I am mostly using Gmail API in automation project to validate emails sent through my company’s system. We can login to Gmail and check the emails from UI but it takes a lot of time and it’s not a good practice to test Gmail in production. So we are using Gmail API. Let’s start
Enable Gmail API
First step is to enable the Google APIs and Service. So you need to go https://console.developers.google.com to activate the API access of the email that you will use in your project. Click ENABLE APIS AND SERVICES. It will take you to the search page.
When you select the GMAIL API, you need to push the ENABLE button. It’s so easy right!
Configure Gmail Consent Screen
In the next screen, you have to select the OAuth consent screen and select External. If you choose Internal, your app will require a verification. Select External and click CREATE button.
Give a name to your application. I added “SWTESTACADEMY” as my project name. There are some already defined Scopes for you. In case you need to do more with Gmail API, just add whatever suite your need. For this tutorial, default ones are ok.
Create GMAIL Credentials
Now, navigate to Credentials page once again. Select CREATE CREDENTIALS on the top menu. Then select OAuth client ID sub menu.