-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SASL works after first authentication, but not later. access-token is nil #17
Comments
It still happens with a recently compiled Emacs (less than a week ago), latest wanderlust+flim. I'm using oauth2 0.16 from ELPA. I think it happens when the old token expires (sasl-xoauth2-token-expired-p). But I manually changed the expiration date in my plstore file to make it expired, I sent an e-mail, and it went through the code to refresh the token („Contacting host: www.googleapis.com:443“ etc.) and it worked and it got one, non-nil, and it saved it into plstore. |
You can use advice for debugging. For example, following code signals error when (advice-add
'plstore-save
:around
(lambda (oldfun &rest r)
(let* ((plstore (car r))
(plist (cdr (plstore-get plstore (caar (plstore--get-alist plstore)))))
(response (plist-get plist :access-response))
(refresh (plist-get plist :refresh-token))
(token (plist-get plist :access-token)))
(if (and response refresh)
(progn (when (null token)
(error "Invalid OAuth2 token!!"))
(message "DEBUG: OAuth2 access token is %s" token))
(message "INFO: may not be OAuth2 token"))
(apply oldfun r)))
'((name . "validate plstore"))) Though I have no idea why your access-token is ;; Refresh token everytime.
(eval-after-load "sasl-xoauth2"
'(defun sasl-xoauth2-token-expired-p (_token) t)) |
Thanks @ikazuhiro, I'll use this for some time to find out why access-token becomes nil. |
I set up Wanderlust to use XOauth2 to connect to Gmail.
I'm not sure my setup is complete, but it seems to work the first time: I'm able to send e-mails through SMTP.
But some days later (sorry, I still don't know how many), when I try to send an e-mail I see:
I debugged the error and I saw it happens here:
As mentioned, the first use works:
If I look at the .plstore file after I get the error, I see something like:
I think the
access-token nil
could be part of the problem. Right after manual synchronization (the first time I set it up) it has a value and it works.The SMTP communication when it fails is:
If I decode the base64-encoded parts above (where I wrote XXXXX), I see that the first one is
user=n……………@gmail.comauth=Bearer nil
and the 2nd one{"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}
.In
.comauth=Bearer nil
, between.com
andauth
there's a the ASCII byte 01. And afterBearer nil
there's 01 01The
Bearer nil
is bad; it should be the access-token. It comes from(format "user=%s\001auth=Bearer %s\001\001"
insasl-xoauth2-response
, and I verified that it's nil. It was nil in the plstore file, and it's nil here.I suggest adding a check somewhere in
(setq access-token (oauth2-token-access-token oauth2-token))
(sasl-xoauth2-response at sasl-xoauth2.el) to verify that it got the token (not nil). This would detect and inform about the error in an easy way before the nil is base64-encoded and sent through SMTP.And I still don't know why or who wrote
access-token nil
into the plstore file. Probably there can be some verification before writing, to make sure we don't writenil
.Versions: Wanderlust/2.15.9 (Almost Unreal), latest flim as of today (2cf5a78)
I can provide more information as I find it, or at your request. I want to keep this error documented here, to help others that see it.
The text was updated successfully, but these errors were encountered: