Gfetch is a Gmail correspondence backup app. It saves raw and cleaned versions of your emails with a specified correspondent to your filesystem. Attachments are saved to their own subfolder. It also lets you delete all the downloaded files with the push of a button.
It started life as a CLI app but I've since converted it into a web app using Flask.
Gfetch is built using Flask 3 and Python 3.12. It uses Redis for server-side caching and Tailwind CSS for styling. It downloads emails using the Gmail API.
For now, you have to install Gfetch locally to use it. You will need Python 3.12 or later (pyenv can help with this), and you must have redis installed and running. Then, follow these steps:
- Clone this repository.
- Navigate to the 'gfetch_web' directory.
- Create a virtual environment:
python -m venv venv
(Windows/Linux) orpython3 -m venv venv
(Mac). - Activate the virtual environment:
.\venv\Scripts\activate
(Windows) orsource venv/bin/activate
. - Install the dependencies. You have two options:
- You can use the pregenerated requirements.txt file:
pip install -r requirements.txt
; or - You can generate a new requirements.txt and install from it with
pip install pip-tools; pip-compile; pip install -r requirements.txt
.
- Create a .env file in the root directory to set the necessary environment variables. I've supplied a file, env-template, that shows what you need and has some default values, but Windows users will need to change the filepath syntax.
- Now you should be able to run the app with
flask run
, but you need to do some further setup via Google Cloud to make it functional.
Since the app is not yet verified or published by Google, you will need to set it up as your own project in Google Cloud:
- Go the the Google Cloud Console and create an account if you don't have one (you will need to input payment info but won't be charged if you have a free trial).
- In the dropdown menu to the right of the Google Cloud logo in the top-left of the screen, select
New Project
. You can name it whatever you like. - Once your project is created it, select it.
- Using the navigation menu in the top-left of the screen, go to
APIs & Services
, thenEnable APIs and Services
. - Search
gmail
in the box and find the Gmail API, then enable it. - In the
APIs & Services
menu, clickCredentials
, then clickCreate Credentials
, thenOAuth Client ID
. - Follow the prompts to generate credentials.
- Once you've created the credentials, you should see them on the main credentials page. Download the credentials JSON. If you're using the values from env-template, you should save it in
gfetch_web/src/app/
with the filenamecredentials.json
. If you save it anywhere else, make sure the CREDS variable in .env points to that file.
- Start Flask:
flask run
. - Ctrl-click on
http://127.0.0.1:5000
— This will open gfetch in your default browser. - Enter an email address in the box and click the Fetch Emails button (You will be redirected to authorize the app via your Google account; choose the account you want to use then press Continue twice).
- If you want to delete the files you downloaded, press the Delete downloaded files button.
- You can close the app by closing your browser and pressing Ctrl-C in the terminal running Flask.
Gfetch is free software, released under version 3.0 of the GPL. Everyone has the right to use, modify, and distribute jazztunes subject to the stipulations of that license.