A Node.js application that helps clean up your Gmail inbox by automatically processing unread emails containing "unsubscribe" text.
- Node.js (v14 or higher)
- npm
- Google Cloud Platform account
- Gmail API enabled
- OAuth 2.0 credentials
-
Clone the repository:
git clone https://github.com/yourusername/gmail-inbox-cleaner.git cd gmail-inbox-cleaner
-
Install dependencies:
npm install
-
Set up Google Cloud Platform:
- Create a new project in Google Cloud Console
- Enable Gmail API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
- http://localhost:3000
- Your ngrok URL (for development)
-
Save your OAuth credentials:
- Download the OAuth credentials from Google Cloud Console
- Save as
credentials.json
in the project root directory
-
Start ngrok:
ngrok http 3000
-
Update the redirect URI:
- Copy your ngrok URL
- Update it in
config/auth.js
- Add it to your OAuth credentials in Google Cloud Console
-
Run the application:
node server.js
- Start the server using
node server.js
- Click the authorization link that appears in the console
- Sign in with your Google account and authorize the application
- The application will automatically process unread emails
Update config/auth.js
with your specific settings:
- REDIRECT_URI: Your ngrok URL or production URL
- SCOPES: Gmail API scopes needed
- TOKEN_PATH: Where to store the OAuth token
The project structure is organized as follows:
config/
: Configuration filesutils/
: Helper utilitiesservices/
: Core service functionalityserver.js
: Main application entry point
gmail-cleaner/
├── config/
│ └── auth.js
├── utils/
│ └── authHelper.js
├── services/
│ └── gmailService.js
├── server.js
├── .gitignore
├── package.json
├── README.md
└── LICENSE
MIT License - See LICENSE file for details