Giter Site home page Giter Site logo

mfauth's Introduction

MFAuth

Multi Factor Authentication CLI

Simple CLI tool to request and manage OAuth2 tokens. Can be used with mbsync and msmtp to receive and send mail with providers requiring OAuth2 authentication.

Installation

  1. Install Rust, either with your package manager or using rustup
  2. Install mfauth using cargo
cargo install mfauth
  1. Test if it works by running mfauth help

If you see a command not found error, you can try putting $HOME/.cargo/bin in your $PATH.

Usage

  1. Run mfauth init to create an example configuration file in $HOME/.config/mfauth/config.toml
  2. Edit the configuration file ($EDITOR $HOME/.config/mfauth/config.toml)
  3. Run mfauth authorize <account> to get a valid session (an access and refresh token), this will save this session in $HOME/.cache/mfauth/cache.toml
  4. Run mfauth access <account> to get a valid access token, this will automatically refresh tokens if needed
  5. Configure your mail client to use XOAUTH2 authentication and use mfauth to fetch the access tokens

Once in a while this might stop working if your session expires. If that happens, you can simply run mfauth authorize <account> again and you're good to go!

Example with msmtp (sending)

A working account entry in the msmtp config using mfauth:

account microsoft
auth xoauth2
from [email protected]
host outlook.office365.com
passwordeval /home/user/.cargo/bin/mfauth access microsoft
port 587
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
user [email protected]

Example with mbsync (receiving)

Important: isync requires the cyrus-sasl-xoauth2 extension installed to support the XOAUTH2 authentication protocol.

This is an example of a working IMAPAccount block using mfauth.

IMAPAccount microsoft
AuthMechs XOAUTH2
CertificateFile /etc/ssl/certs/ca-certificates.crt
Host outlook.office365.com
PassCmd "/home/user/.cargo/bin/mfauth access microsoft"
Port 993
SSLType IMAPS
User [email protected]

mfauth's People

Contributors

chvp avatar rien avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

chvp

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.