Skip to content

Commit dbbf854

Browse files
gptel-gh: Do not write token in message log when using init function
1 parent 76a1010 commit dbbf854

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

gptel-gh.el

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,9 @@
194194
(setq hex (nconc hex (list (aref hex-chars (random 16))))))
195195
(apply #'string hex)))
196196

197-
(defun gptel--gh-save (obj)
198-
"Save OBJ to FILE."
199-
(message "New GitHub token: %s" (prin1-to-string obj))
200-
(setq gptel--gh-github-token obj))
197+
(defun gptel--gh-github-token-save (token)
198+
"Saves the new github token for use."
199+
(setq gptel--gh-github-token token))
201200

202201
(defun gptel-gh-login ()
203202
"Login to GitHub Copilot API.
@@ -229,10 +228,12 @@ If your browser does not open automatically, browse to %s."
229228
:device_code ,device_code
230229
:grant_type "urn:ietf:params:oauth:grant-type:device_code"))
231230
:access_token)
232-
(gptel--gh-save))
231+
(gptel--gh-github-token-save))
233232
(if (and gptel--gh-github-token
234233
(not (string-empty-p gptel--gh-github-token)))
235-
(message "Successfully logged in to GitHub Copilot")
234+
(progn
235+
(message "New GitHub token: %s" (prin1-to-string gptel--gh-github-token))
236+
(message "Successfully logged in to GitHub Copilot"))
236237
(user-error "Error: You might not have access to GitHub Copilot Chat!"))))
237238

238239
(defun gptel--gh-renew-token ()
@@ -336,7 +337,7 @@ for."
336337
(declare (indent 1))
337338
(if (and (not gptel--gh-github-token)
338339
github-token-init)
339-
(gptel--gh-save (funcall github-token-init)))
340+
(gptel--gh-github-token-save (funcall github-token-init)))
340341
(let ((backend (gptel--make-gh
341342
:name name
342343
:host host

0 commit comments

Comments
 (0)