You are not logged in.

#1 2021-01-23 14:42:27

rahulgoel
Member
Registered: 2020-09-17
Posts: 4

OAuth 2 for Office365 with isync/msmtp

I come here after spending a lot of time exploring the problem and looking for solutions online.
I want an offline email setup with NeoMutt. For that I am trying to get my isync and msmtp to work. However both of them are not working.

This is what happens when I try to login into my university's email account.
- I go to outlook.com and put in my university email and click on login.
- The page redirects to my university's CAS (Central Authentication Service)
- I enter my email and password over there and I get logged in and the page redirects to oulook email again.

After searching online, I came to know that this process is called OAuth2.

I want to access to my email repository through isync but my credentials don't work over there. This is obviously because when the request is made to outlook, it treats it as a regular outlook account rather than an OAuth one.
How do I get around this? There are guides to get around GMail for this. There was another guide for Outlook (on the official website) but by reading it, I think it is for OAuth by Office365 (Some other application using Office365 for authentication).

So that is the situation. Has anyone overcome this kind of situation? Could anyone guide me on this?
Also whatever the solution is I think it should work for both isync and msmtp.

Last edited by rahulgoel (2021-01-23 14:49:14)

Offline

#2 2021-01-23 15:21:21

progandy
Member
Registered: 2012-05-17
Posts: 5,321

Re: OAuth 2 for Office365 with isync/msmtp

This one should do: https://github.com/tarickb/sasl-xoauth2.
You'll have to change the SCOPE in get-initial-outlook-tokens.py and in the client registration to include IMAP access:

SCOPE = "openid offline_access https://outlook.office.com/SMTP.Send https://outlook.office.com/IMAP.AccessAsUser.All"

https://docs.microsoft.com/exchange/cli … sing-oauth


Then in isync you need to set a PassCmd that returns the path of the file containing the oauth2 token. (the output-token-file given to get-initial-outlook-tokens.py)

AuthMechs XOAUTH2
PassCmd="printf '%s' ~/path_to/output-token-file"

Edit: Most likely you should also be able to use the method described in the wiki: https://wiki.archlinux.org/index.php/Is … ng_XOAUTH2 instead after you registered and used get-initial-outlook-tokens.py to fetch the tokens.

I haven't tested it, but this is an educated guess  due to my experiments with an older (worse) oauth plugin: https://bbs.archlinux.org/viewtopic.php?id=238727

You might have issues if your CAS does not accept your client identifier. In that case you could ask you university to give you a client token / allow your token access or possibly try to extract the identifier from another permitted client (which would be against TOS)

Edit: If IMAP is disabled or you can't get a working client identifier, you might still be able to use DavMail and the EWS protocol: http://davmail.sourceforge.net/faq.html

Last edited by progandy (2021-01-23 15:56:51)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#3 2021-01-23 16:31:34

rahulgoel
Member
Registered: 2020-09-17
Posts: 4

Re: OAuth 2 for Office365 with isync/msmtp

@progandy Thanks for the detailed comment. I'll try the methods stated by you in the next day or so and update the thread with the result.

Offline

#4 2021-01-24 12:43:14

rahulgoel
Member
Registered: 2020-09-17
Posts: 4

Re: OAuth 2 for Office365 with isync/msmtp

So it turns out that CAS and OAuth are actually different. It won't work with the OAuth methods. I'll ask my univeristy authorities and try to figure it out.
Thanks for your help smile

Offline

Board footer

Powered by FluxBB