Skip to content

Commit

Permalink
Don't inhibit EOL conversion for oauth2.el.
Browse files Browse the repository at this point in the history
oauth2.el internally calls url package, which loads saved cookie
file.  The file has file variables and saved as DOS EOL on
Windows.  When EOL conversion is inhibited, loading such file
fails.  As workaround, explicitly enable EOL conversion in calling
oauth2 functions explicitly

* sasl-xoauth2.el (sasl-xoauth2-refresh-access)
(sasl-xoauth2-response): As above.
  • Loading branch information
ikazuhiro committed Feb 5, 2023
1 parent be07909 commit 2cf5a78
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions sasl-xoauth2.el
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ host, regexp for User ID, client ID and client secret (optional).
(defun sasl-xoauth2-refresh-access (token)
"Refresh OAuth access TOKEN.
TOKEN should be obtained with `oauth2-request-access'."
(let ((response
(oauth2-make-access-request
(oauth2-token-token-url token)
(concat "client_id=" (oauth2-token-client-id token)
"&client_secret=" (oauth2-token-client-secret token)
"&refresh_token=" (oauth2-token-refresh-token token)
"&grant_type=refresh_token"))))
;; url package would fail on Windows without EOL conversion.
(let* ((inhibit-eol-conversion nil)
(coding-system-for-read nil)
(response
(oauth2-make-access-request
(oauth2-token-token-url token)
(concat "client_id=" (oauth2-token-client-id token)
"&client_secret=" (oauth2-token-client-secret token)
"&refresh_token=" (oauth2-token-refresh-token token)
"&grant_type=refresh_token"))))
(setf (oauth2-token-access-token token)
(cdr (assq 'access_token response)))
;; Update authorization time.
Expand Down Expand Up @@ -202,6 +205,9 @@ TOKEN should be obtained with `oauth2-request-access'."
(defun sasl-xoauth2-response (client _step &optional _retry)
(let ((host (sasl-client-server client))
(user (sasl-client-name client))
;; url package would fail on Windows without EOL conversion.
(inhibit-eol-conversion nil)
(coding-system-for-read nil)
info access-token oauth2-token
auth-url token-url client-id scope redirect-uri client-secret)
(setq info (sasl-xoauth2-resolve-urls host user)
Expand Down

0 comments on commit 2cf5a78

Please sign in to comment.