mutt-office365 icon indicating copy to clipboard operation
mutt-office365 copied to clipboard

OAuth2 support

Open wouter-swierstra opened this issue 4 years ago • 8 comments

I was wondering if anyone has had any luck configuring mutt and office365 to use two factor authentication (and OAuth2 in particular). I've seen a few Python scripts that can be used to get/store OAuth2 tokens to access gmail using mutt -- but nothing similar for office 365.

PS - Thanks for putting this online! It's very useful indeed.

wouter-swierstra avatar Jun 29 '20 11:06 wouter-swierstra

@wouter-swierstra just in case you're not aware of this already, there is a way to use mutt with Microsoft/Office365 accounts. You download a script and follow the instructions in the README:

  • https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py.README
  • https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py

I did not have success connecting it to a company account but have heard of people where this method works for their personal account. (If anyone successfully connects to a company/AzureAD Office365 account with it, please ping me.)

moertel avatar Sep 27 '20 10:09 moertel

@moertel Yes -- I saw that the mutt developers have been adding support for this - which is great news! I haven't upgraded my mutt client to the latest version, so I haven't looked into this yet. I have managed to set up the Azure developer permissions, which have let me login, send and receive email using a Python script. Once a newer mutt version lands in Ubuntu, I'm hopeful things should work.

wouter-swierstra avatar Sep 28 '20 07:09 wouter-swierstra

@wouter-swierstra just in case you're not aware of this already, there is a way to use mutt with Microsoft/Office365 accounts. You download a script and follow the instructions in the README:

  • https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py.README
  • https://gitlab.com/muttmua/mutt/-/blob/master/contrib/mutt_oauth2.py

I did not have success connecting it to a company account but have heard of people where this method works for their personal account. (If anyone successfully connects to a company/AzureAD Office365 account with it, please ping me.)

I have had the same problem. I think one needs to register an app to get a client id. But my organizations o365 admin has disabled this registering. Also I have always been getting an error while using the IMAP with mutt 'BAD User is authenticated but not connected.' I have tried everything but nothing works. Would love to use mutt again

vamsikrishnav avatar Jan 14 '21 14:01 vamsikrishnav

@moertel I can successfully connect to a company Office365 account with mutt. When following mutt_oauth2.py.README, make sure to comment (delete) the values (e.g. imap_user, folder...) in user and muttrc. The values provided by the config from this repo are not applicable for OAuth2 so you need to make sure you have overrided the values with the correct ones according to the README.

For @vamsikrishnav 's issue, you can follow the instructions in mutt_oauth2.py.README and try contacting your organization's admin first. If that fails you can try logging in to your Office365 account with another well-known IMAP/POP/SMTP client (such as the one starting with letter "T", which is a free and open-source cross-platform email client). If that client works, then:

you could dig into the source code for that client and extract its client_id, client_secret, and redirect_uri and put those into the mutt_oauth2.py script. This would be a temporary punt for end-user experimentation, but not an approach for configuring systems to be used by other people. Engaging your institution admins to create a mutt registration is the better way to go.

ghost avatar Aug 27 '21 00:08 ghost

FWIW https://www.vanormondt.net/~peter/blog/2021-03-16-mutt-office365-mfa.html

andhe avatar Oct 15 '21 10:10 andhe

@jloqfjgk Could you please elaborate on finding the client_id and secred and redirect_uri? Where would I look for this? I was able to get Thunderbird do this with no problems, but I would prefer using mutt. Thank you!

meredithkr avatar Oct 24 '21 21:10 meredithkr

@andhe

I tried following those instructions, but the first problem I am having is that TOKEN_FILE they mention. I am assuming I need to obtain that before running the oauth2 script, correct? How do I go about that? Thank you!

meredithkr avatar Oct 24 '21 22:10 meredithkr

@andhe

I tried following those instructions, but the first problem I am having is that TOKEN_FILE they mention. I am assuming I need to obtain that before running the oauth2 script, correct? How do I go about that? Thank you!

The TOKEN_FILE is a file that stores the token created bu the oauth2 script.

It's an output file, not an input one.

raffaem avatar Oct 06 '22 16:10 raffaem