The goal of this project is to implement a Spring Boot Web Java application that communicates with a GMail inbox account using GMail API.
| Important | For now, the project is frozen due to changes in Google API | 
- 
Access https://developers.google.com/gmail/api/quickstart/java and go to Step 1: Turn on the GMail API;
- 
Click on the blue button Enable the GMail API;
- 
A window with title Enable the Gmail APIwill open. In the fieldEnter new project name, you can keep the defaultQuickstart. Then, click onNextbutton;
- 
On the next window with title Configure your OAuth client, keep theDesktop appselected (default) and click onCREATEbutton;
- 
A window with title You’re all set!will open. Write downclient_idandclient_secret. They will be used on the next steps. Then, click onDonebutton;
- 
In order to receive a callback from Google, let’s start springboot-gmailapplication. So, open a terminal and insidespringboot-gmailfolder, run the following command./mvnw clean spring-boot:run
- 
Open a browser and access the link below informing the client_id(obtained in the step 5.) and the scope that you allow the application to have;CautionIn this link, we are using the scope https://mail.google.com. It allows full access to the account! For more information about scopes, please check https://developers.google.com/gmail/api/auth/scopes. https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=CLIENT_ID&scope=https://mail.google.com&redirect_uri=http://localhost:8080/callback
- 
Choose your Google account; 
- 
A message will appear saying that Google hasn’t verified this app. Click onAdvancedand then onGo to Quickstart (unsafe)
- 
Allow Quickstartto access your Google Account. You will get acodeafter completing all allowance steps. Write down thiscode. It will be used on the next step;
- 
Open a new terminal and run the following command, replacing CODE(obtained in the previous step),CLIENT_IDandCLIENT_SECRET(both obtained in the step 4.)curl -i -X POST https://www.googleapis.com/oauth2/v4/token \ -d "grant_type=authorization_code" \ -d "code=CODE" \ -d "client_id=CLIENT_ID" \ -d "client_secret=CLIENT_SECRET" \ -d "redirect_uri=http://localhost:8080/callback"It should return something like HTTP/2 200 ... { "access_token": "ya29.a0AfH6...v0cIbuQ", "expires_in": 3599, "refresh_token": "1//030V4mwr2...jLNKI", "scope": "https://mail.google.com/", "token_type": "Bearer" }
- 
Done! Now we have all the credentials needed to access GMail account, i.e, client_id,client_secretandrefresh_token;
- 
Shutdown the springboot-gmailapplication by pressingCtrl+C.
- 
In a terminal, make sure you are inside springboot-gmailroot folder
- 
Export the values of client_id,client_secretandrefresh_tokento their respective environment variableexport GMAIL_CLIENT_ID=... export GMAIL_CLIENT_SECRET=... export GMAIL_REFRESH_TOKEN=...
- 
Run the following command to start the application ./mvnw clean spring-boot:run
- 
springboot-gmailSwagger website can be accessed at http://localhost:8080/swagger-ui.html
- 
Get labels curl http://localhost:8080/api/labels
- 
Get messages curl http://localhost:8080/api/messages
- 
Get threads curl http://localhost:8080/api/threads
- 
In a browser, access https://myaccount.google.com/permissions
- 
In Third-party apps with account accesssection, selectQuickstart
- 
Finally, click on REMOVE ACCESSbutton.
- 
Click on OKto confirm the removal.


