java-gmail-api
Ever wanted to clone Gmail Inbox functionalities (Send Message, Read Message, Delete Message, Manage Gmail Inbox) ? Now you can.
How to run this project:
- Enable the Gmail API the Gmail API from your Google API Developer Console.
- Obtain Credentials of type "OAuth Client ID". If GDC asks you to specify "OAuth consent screen" first, just choose "External".
- Credential's Application type will be "Desktop application".
- Since you will be testing on your local environment for now, use "http://localhost" for both "Authorised Javascript origins" and "Authorised redirect URIs"
- Click the download button on the far right corner of your clientID.
- Open the downloaded credentials.json file and populate the existing credentials.json file on this project located at "src/main/java/credentials.json"
- You are now ready to run the project. On your first attempt, Gmail will open a browser for this java application to be authorized. Click 'Allow'.
I have already setup this project so your 'access tokens' are located at "gmail-api-java/tokenLocatedHere". The Google Gmail API Quickstart doesn't mention where this is located. It's usually a 'hidden file' and it becames troublesome when you want to change the scope (read-only, write ,etc) of your application. Everytime you need to change the scope of your app, you have to delete this token for the new scope to take effect. The default scope of this java application is set to "all powerful" which means it can perform all the Gmail API tasks.
Gmail API Scope:
If you wish to change the scope of this application, you can use Java Gmail Scopes as reference and their corresponding definition in Gmail API authorization docs.