gpt-commit
gpt-commit copied to clipboard
Read api key from .authinfo for better security
It'd be great if there's a way to pull api keys from .authinfo. An added benefit is that if that file is encrypted with gpg, emacs will handle that transparently.
An example of how to do this is as follows:
Assuming following is present in .authinfo or .authinfo.gpg:
machine api.openai.com login apikey password 1234567890
This bit of emacs lisp returns the password (api key):
(encode-coding-string (funcall
(plist-get (car
(auth-source-search :host "api.openai.com" :user "apikey" :require '(:secret)))
:secret)) 'utf-8)
;; => "1234567890"
I'll look at making a PR with this once I get some more time.