Mew icon indicating copy to clipboard operation
Mew copied to clipboard

XOAUTH2 support

Open tats opened this issue 2 years ago • 2 comments

TODO:

  • [x] Add XOAUTH2 support, merge from https://github.com/yoshinari-nomura/Mew/tree/mew-support-xoauth2
  • [X] Use json-read-from-string instead of json-parse-string for Emacs 26
  • [x] Disable XOAUTH2 by default, especially to use IMAP PLAIN
  • [ ] Support mew-config-alist to use XOAUTH2 for each servers
  • [ ] Update documentation for XOAUTH2 in info/mew.texi

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

tats avatar Feb 18 '23 02:02 tats

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.

murawaki avatar Aug 31 '24 07:08 murawaki

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.

nbkenichi avatar Sep 05 '24 01:09 nbkenichi