In my recent project I need to access the email from gmail inbox. I implemented the functionality but there is an issue when I implemented this, the issue is that user has to enable the less secure sign-in technology  if they want that app should read the inbox mails. That sounds odd, then I found the solution for this on oracle site faq where they have suggested for Oauth2.

To do the authorisation with Oauth2 you need to go through the following steps.

1. Obtain OAuth 2.0 credentials from the Google API Console.

2. Obtain an access token from the Google Authorization Server.

To obtain the access token you first required to get an oauth code, which you can obtain as:

You will get oauth code on the url which you have provided in the google API console in my case redirect url is:


Now you will be able to connect with gmail store without enabling the less secure sign-in technology as  user logs in with their Google account. After logging in, the user is asked whether they are willing to grant the permissions that your application is requesting. This process is called user consent.

and you ready to connect with gmail with auth access tokenstore as:

Here I am using Javamail version 1.5.6