Skip to content

Commit 7fa9017

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

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
@@ -200,10 +200,9 @@
200200
(setq hex (nconc hex (list (aref hex-chars (random 16))))))
201201
(apply #'string hex)))
202202

203-
(defun gptel--gh-save (obj)
204-
"Save OBJ to FILE."
205-
(message "New GitHub token: %s" (prin1-to-string obj))
206-
(setq gptel--gh-github-token obj))
203+
(defun gptel--gh-github-token-save (token)
204+
"Saves the new github token for use."
205+
(setq gptel--gh-github-token token))
207206

208207
(defun gptel-gh-login ()
209208
"Login to GitHub Copilot API.
@@ -235,10 +234,12 @@ If your browser does not open automatically, browse to %s."
235234
:device_code ,device_code
236235
:grant_type "urn:ietf:params:oauth:grant-type:device_code"))
237236
:access_token)
238-
(gptel--gh-save))
237+
(gptel--gh-github-token-save))
239238
(if (and gptel--gh-github-token
240239
(not (string-empty-p gptel--gh-github-token)))
241-
(message "Successfully logged in to GitHub Copilot")
240+
(progn
241+
(message "New GitHub token: %s" (prin1-to-string gptel--gh-github-token))
242+
(message "Successfully logged in to GitHub Copilot"))
242243
(user-error "Error: You might not have access to GitHub Copilot Chat!"))))
243244

244245
(defun gptel--gh-renew-token ()
@@ -342,7 +343,7 @@ for."
342343
(declare (indent 1))
343344
(if (and (not gptel--gh-github-token)
344345
github-token-init)
345-
(gptel--gh-save (funcall github-token-init)))
346+
(gptel--gh-github-token-save (funcall github-token-init)))
346347
(let ((backend (gptel--make-gh
347348
:name name
348349
:host host

0 commit comments

Comments
 (0)