Git Product home page Git Product logo

gomuche's Introduction

gomuche

gomuche stands for Google Mail unread count checker.

Motivation

This tool in fact does this:

curl -su $GMAIL_USER:$GMAIL_PASS https://mail.google.com/mail/feed/atom
# and parsing it further

But instead of user+pass authentication, this tool uses OAUTH2 which is way more secure. Unencrypted Google password stored in some plain text file (to use in ENV_VARIABLE like above) may be leaked. In opposite, storing just an auth token is no big deal.

This tool was written mostly for demonstrational purposes, but actually I use it for my i3blocks mail checker here.

Installation

go get github.com/hypnoglow/gomuche

Usage

Go to Google Developers Console and create your credentials: client ID and client secret. For instance, consider the following steps:

  1. Create a new project.
  2. Navigate to "credentials".
  3. Click "create credentials".
  4. Select "Help me choose".
  5. Which API are you using? - Gmail API
  6. Where will you be calling the API from? - Other UI (CLI tool)
  7. What data will you be accessing? - User data.

Get your credentials.

Run:

gomuche auth --client-id YOUR_CLIENT_ID --client-secret YOUR_CLIENT_SECRET

Your credentials will be saved in $HOME/.gomuche/config.json so you can run gomuche auth without arguments in the future.
This command will print the link you need to open in your browser to authorize. You will be given a code. Copy it and run mail check passing this code:

gomuche check -c YOUR_CODE

It creates your auth token, which will be stored in $HOME/.gomuche/token.json. Next time you should run mail check without passing the code:

gomuche check

It will use your stored token, and automatically refresh it when it expires.

Note that you cannot use the same code again. You must obtain a new one from gomuche auth to make a new token if you lose yours.

For any additional info, run:

gomuche --help

Issues

If you experience any problems (e.g. program exits with non-zero exit code), you can add -v flag to check command to print output verbosely. Also, you can check error log, which is located in $HOME/.gomuche/gomuche.log.

If you found any bug, feel free to create a GitHub issue or/and submit a pull request.

License

MIT

gomuche's People

Contributors

hypnoglow avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.