Function: url-digest-find-creds

url-digest-find-creds is a byte-compiled function defined in url-auth.el.gz.

Signature

(url-digest-find-creds URL PROMPT &optional REALM)

Documentation

Find or ask credentials for URL.

Primary method for finding credentials is from Emacs auth-source. If password isn't found, and PROMPT is non-nil, query credentials via minibuffer. Optional REALM may be used when prompting as a hint to the user.

Return value is nil in case either user name or password wasn't found. Otherwise, it's a plist containing :user and :secret. Additional :source property denotes the origin of the credentials and its value can be either symbol authsource or interactive.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-auth.el.gz
(defun url-digest-find-creds (url prompt &optional realm)
  "Find or ask credentials for URL.

Primary method for finding credentials is from Emacs auth-source.
If password isn't found, and PROMPT is non-nil, query credentials
via minibuffer.  Optional REALM may be used when prompting as a
hint to the user.

Return value is nil in case either user name or password wasn't
found.  Otherwise, it's a plist containing `:user' and `:secret'.
Additional `:source' property denotes the origin of the
credentials and its value can be either symbol `authsource' or
`interactive'."
  (let ((creds (url-digest-auth-source-creds url)))

    ;; If credentials weren't found and prompting is allowed, prompt
    ;; the user.
    (if (and prompt
             (or (null creds)
                 (null (plist-get creds :secret))))
        (progn
          (setq creds (url-digest-prompt-creds url realm creds))
          (plist-put creds :source 'interactive))
      (plist-put creds :source 'authsource))

    (and (plist-get creds :user)
         (plist-get creds :secret)
         creds)))