Skip to content

Commit c293cbf

Browse files
gptel-gh: Do not write token in message log when using init function
1 parent 213f9cc commit c293cbf

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
@@ -216,10 +216,9 @@
216216
(setq hex (nconc hex (list (aref hex-chars (random 16))))))
217217
(apply #'string hex)))
218218

219-
(defun gptel--gh-save (obj)
220-
"Save OBJ to FILE."
221-
(message "New GitHub token: %s" (prin1-to-string obj))
222-
(setq gptel--gh-github-token obj))
219+
(defun gptel--gh-github-token-save (token)
220+
"Saves the new github token for use."
221+
(setq gptel--gh-github-token token))
223222

224223
(defun gptel-gh-login ()
225224
"Login to GitHub Copilot API.
@@ -251,10 +250,12 @@ If your browser does not open automatically, browse to %s."
251250
:device_code ,device_code
252251
:grant_type "urn:ietf:params:oauth:grant-type:device_code"))
253252
:access_token)
254-
(gptel--gh-save))
253+
(gptel--gh-github-token-save))
255254
(if (and gptel--gh-github-token
256255
(not (string-empty-p gptel--gh-github-token)))
257-
(message "Successfully logged in to GitHub Copilot")
256+
(progn
257+
(message "New GitHub token: %s" (prin1-to-string gptel--gh-github-token))
258+
(message "Successfully logged in to GitHub Copilot"))
258259
(user-error "Error: You might not have access to GitHub Copilot Chat!"))))
259260

260261
(defun gptel--gh-renew-token ()
@@ -358,7 +359,7 @@ for."
358359
(declare (indent 1))
359360
(if (and (not gptel--gh-github-token)
360361
github-token-init)
361-
(gptel--gh-save (funcall github-token-init)))
362+
(gptel--gh-github-token-save (funcall github-token-init)))
362363
(let ((backend (gptel--make-gh
363364
:name name
364365
:host host

0 commit comments

Comments
 (0)