kazu-yamamoto / Mew

Messaging in the Emacs World
http://www.mew.org/
Other
191 stars 51 forks source link

XOAUTH2 support #172

Open tats opened 1 year ago

tats commented 1 year ago

TODO:

cf. https://groups.google.com/g/mew-ja/c/Hn9L27ll-eY

murawaki commented 2 weeks ago

I'm setting up Mew on behalf of a long-time user who is having difficulty transitioning to Gmail POP/SMTP Oauth2 authentication (The deadline for the transition from password login is September 30. It would be helpful if version 6.10 could be released before then). I should note that I have limited experience with Mew and Elisp.

With the latest commit (0738a224a375e3922dd2d05069d3aaa8c2383fa6), I successfully retrieved emails using IMAP and sent emails using SMTP. However, when I switched to using POP as requested, I encountered an issue.

When attempting to retrieve emails using POP, the following error appeared in the *Messages* buffer:

error in process sentinel: mew-pop-sentinel: Wrong type argument: number-or-marker-p, "auth-xoauth2" error in process sentinel: Wrong type argument: number-or-marker-p, "auth-xoauth2"

I believe the following line is wrong: https://github.com/kazu-yamamoto/Mew/blob/0738a224a375e3922dd2d05069d3aaa8c2383fa6/elisp/mew-pop.el#L520

Replacing mew-smtp-set-status with mew-pop-set-status resolved the error

Now I am receiving a "No new messages" response. I'm unsure if this is the correct behavior or if it indicates a different problem.

nbkenichi commented 1 week ago

70b5787 seems to have three issues. Issue A. Constatnt 8080 is used as a port of http redirect server for XOAUTH2. https://github.com/kazu-yamamoto/Mew/blob/70b57878d5f7f9f81ff125b7ce52785ccbe8b46b/elisp/mew-oauth2.el#L200

Issue B. The regexp doesn't seem to catch a code from login.microsoftonline.com. https://github.com/kazu-yamamoto/Mew/blob/70b57878d5f7f9f81ff125b7ce52785ccbe8b46b/elisp/mew-oauth2.el#L71

Issue C. After success of XOAUTH2, a token(hash) is stored in a password file or variable. But mew-input-passwd seems to assume a password(string) is stored. (or nil) Therefore, mew-input-passwd might hangs up in PLAIN authorization after XOAUTH2. Type of returned value from mew-passwd-get-passwd should be checked. If it isn't string, a password should be typed in by a user. https://github.com/kazu-yamamoto/Mew/blob/70b57878d5f7f9f81ff125b7ce52785ccbe8b46b/elisp/mew-passwd.el#L233

Only issue A and B are resolved in #195.