Skip to content

Commit 5304345

Browse files
gptel-gh: Do not write token in message log when using init function
1 parent 7bf6f2d commit 5304345

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
@@ -210,10 +210,9 @@
210210
(setq hex (nconc hex (list (aref hex-chars (random 16))))))
211211
(apply #'string hex)))
212212

213-
(defun gptel--gh-save (obj)
214-
"Save OBJ to FILE."
215-
(message "New GitHub token: %s" (prin1-to-string obj))
216-
(setq gptel--gh-github-token obj))
213+
(defun gptel--gh-github-token-save (token)
214+
"Saves the new github token for use."
215+
(setq gptel--gh-github-token token))
217216

218217
(defun gptel-gh-login ()
219218
"Login to GitHub Copilot API.
@@ -245,10 +244,12 @@ If your browser does not open automatically, browse to %s."
245244
:device_code ,device_code
246245
:grant_type "urn:ietf:params:oauth:grant-type:device_code"))
247246
:access_token)
248-
(gptel--gh-save))
247+
(gptel--gh-github-token-save))
249248
(if (and gptel--gh-github-token
250249
(not (string-empty-p gptel--gh-github-token)))
251-
(message "Successfully logged in to GitHub Copilot")
250+
(progn
251+
(message "New GitHub token: %s" (prin1-to-string gptel--gh-github-token))
252+
(message "Successfully logged in to GitHub Copilot"))
252253
(user-error "Error: You might not have access to GitHub Copilot Chat!"))))
253254

254255
(defun gptel--gh-renew-token ()
@@ -352,7 +353,7 @@ for."
352353
(declare (indent 1))
353354
(if (and (not gptel--gh-github-token)
354355
github-token-init)
355-
(gptel--gh-save (funcall github-token-init)))
356+
(gptel--gh-github-token-save (funcall github-token-init)))
356357
(let ((backend (gptel--make-gh
357358
:name name
358359
:host host

0 commit comments

Comments
 (0)