Get keys from auth source

This commit is contained in:
Marcus Kammer 2024-04-12 12:16:21 +02:00
parent 7b8f5b054a
commit 4cb806633a

View file

@ -208,3 +208,19 @@
(interactive "sEnter the URL to mirror: ")
(let ((cmd (format "wget --mirror --convert-links --adjust-extension --page-requisites --no-parent %s" url)))
(async-shell-command cmd)))
(defun mk/get-auth-source-key (host key)
"Retrieve the API key using 'auth-source'."
(require 'auth-source)
(let* ((auth-source-creation-prompts
'((secret . (format "API key for %s@%s: " key host))))
(found (nth 0 (auth-source-search
:max 1
:host host
:user key
:require '(:secret)
:create t)))
(secret (plist-get found :secret)))
(if (functionp secret)
(funcall secret)
secret)))