A JSON API proxy for talking to Gmail. Allows using persistent IMAP connections for non-resident scripting languages.
Clone the repo and start the application.
You can then browse the web application at:
All endpoints (except /api) require you send the following parameters:
email - Your Gmail email address access_token - A valid OAuth access token
By default For the 'All Mail' folder Groxy uses '[Gmail]/All Mail' - which will be incorrect for Google Mail accounts (and possibly others) which use '[Google Mail]/All Mail'.
To specify another folder to use the folder parameter to give its name. But be aware that the message IDs returned are folder specific, so you'll need to use these consistently.
The endpoint searches the 'All Mail' folder.
query - Your query string (supports X-GM-RAW extension) folder - The name of the folder to use
messageid - The ID of the message to fetch folder - The name of the folder to use
You will also need specify the following parameters. This will stream back the raw content for the attachment.
messageid - The ID of the attachments message attachmentid - The ID of the attachment to fetch folder - The name of the folder to use
Obtaining and refreshing access tokens is not handled by Groxy, you need to do this yourself. If you make a request with an invalid access token you'll receive a 403 response, which is your notification to refresh your token and try again.
To try Groxy out the easiest way is to get an access token from the OAuth Playground. But don't select the Gmail service listed, enter the scope explicitly as...
Configuration is supplied via environment variables with the GROXY prefix.
GROXY_PORT=4545 GROXY_LOGFILE="logs/access.log" GROXY_LOGLEVEL="debug" GROXY_LOGPATTERN="%d %m"
By default Groxy will cache messages in memory using an LRU cache. To enable a database cache (via JDBC) you can configure it as follows...
GROXY_DB_CACHE_TYPE="mysql" GROXY_DB_CACHE_DSN="//127.0.0.1:3306/db_name" GROXY_DB_CACHE_USER="root" GROXY_DB_CACHE_PASS=""
This will provide a durable cache that survives restarts.
Logging is configured to use log4j, and writes to the log file configured by GROXY_LOGFILE.
The library uses some Java classes to implement the custom Gmail X-GM-RAW IMAP extension. There are stored in src/java. You can compile these on their own using Leiningen.
They will be built automatically once though when running the project (or via REPL).
Documentation can be generated with Marginalia via Leiningen:
And is then available in the docs folder.
You can build a standalone WAR file for deployment using:
lein ring uberwar
This will build a version numbered file in target/groxy-X.X.X.war. Alternatively you can build an executable:
The task will output the name of the executable built, but it should be target/groxy