harishkrupo / oauth2ms

Apache License 2.0
75 stars 24 forks source link

NO AUTHENTICATE #2

Closed johnhamelink closed 3 years ago

johnhamelink commented 3 years ago

Hi there,

I finally got a chance to try out this project on Saturday, but I've not been able to get it working with mbsync:

IMAPAccount mc
Host outlook.office365.com
Port 993
User john@mc.com
PassCmd "oauth2ms"
SSLType IMAPS
AuthMechs XOAUTH2

IMAPStore mc-remote
Account mc

MaildirStore mc-local
Path ~/.mail/john@mc.com/
Inbox ~/.mail/john@mc.com/INBOX
# The SubFolders option allows to represent all
# IMAP subfolders as local subfolders
SubFolders Verbatim

Channel mc
Master :mc-remote:
Slave :mc-local:
Patterns *
Expunge None
CopyArrivalDate yes
Sync All
Create Slave
SyncState *
mbsync -l mc
IMAP command 'AUTHENTICATE XOAUTH2 <base64 hash>' returned an error: NO AUTHENTICATE failed.

The base64 hash looks like this when deserialized (I replaced some of the token to make it wrong):

user=john@mc.comauth=Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6InJfMEU5VDU3aUh1Z21aaXXaaaaAaAaAA1aaA3AaAAa3A2AAAaA

The permissions look like this: Untitled

harishkrupo commented 3 years ago

You can try a few things:

stefanSchuhbaeck commented 3 years ago

Hi not sure if this is the same issue but I saw a similar behavior.

Setup:

If I execute oauth2ms directly the token is quite big (1879 characters). Comparing this with the <base64 hash> returned by mbsync in the error message it is clear that they do not match (length-wise). After some digging on Stack-overflow and Stack-exchange I found this post 'Configuring mbsync with AuthMech XOAUTH2'. It seems that mbsync as a max buffer of 80 chars on the PassCmd buffer which will not work for XOAUTH2. Compiling isync/mbsyng version 1.4.0 did the trick for me.

harishkrupo commented 3 years ago

@stefanSchuhbaeck Thanks for tracking that down! I will update the readme with this requirement.

johnhamelink commented 3 years ago

@stefanSchuhbaeck this is great, I was able to get my mailbox syncing after ugprading isync to 1.4! My problem was that I was using a fork which wasn't being updated.

averter commented 2 years ago

@stefanSchuhbaeck Thanks for tracking that down! I will update the readme with this requirement.

@harishkrupo Have you updated the document? The readme reads as "Requires mbsync >= 1.3. " which implies that 1.3 would work? Is it a typo?

kxxdhdn commented 1 year ago

Hi, I am afraid that the same problem still exists with isync verison=1.4.4 ? I cannot make oauth2ms work after following all the solutions I could find.