Function: magit-process-password-auth-source
magit-process-password-auth-source is a byte-compiled function defined
in magit-process.el.
Signature
(magit-process-password-auth-source KEY)
Documentation
Use auth-source-search to get a password.
If found, return the password. Otherwise, return nil.
KEY typically derives from a prompt such as:
Password for 'https://yourname@github.com'
in which case it would be the string
yourname@github.com
which matches the ~/.authinfo.gpg entry
machine github.com login yourname password 12345
or iff that is undefined, for backward compatibility
machine yourname@github.com password 12345
On github.com you should not use your password but a personal access token, see [1]. For information about the peculiarities of other forges, please consult the respective documentation.
After manually editing ~/.authinfo.gpg you must reset
the cache using
\M-x auth-source-forget-all-cached \RET
The above will save you from having to repeatedly type
your token or password, but you might still repeatedly
be asked for your username. To prevent that, change an
URL like
https://github.com/foo/bar.git
to
https://yourname@github.com/foo/bar.git
Instead of changing all such URLs manually, they can
be translated on the fly by doing this once
git config --global url.https://yourname@github.com.insteadOf https://github.com
[1]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token.
Source Code
;; Defined in ~/.emacs.d/elpa/magit-20260411.1452/magit-process.el
(defun magit-process-password-auth-source (key)
"Use `auth-source-search' to get a password.
If found, return the password. Otherwise, return nil.
KEY typically derives from a prompt such as:
Password for \\='https://yourname@github.com\\='
in which case it would be the string
yourname@github.com
which matches the ~/.authinfo.gpg entry
machine github.com login yourname password 12345
or iff that is undefined, for backward compatibility
machine yourname@github.com password 12345
On github.com you should not use your password but a
personal access token, see [1]. For information about
the peculiarities of other forges, please consult the
respective documentation.
After manually editing ~/.authinfo.gpg you must reset
the cache using
\\`M-x' `auth-source-forget-all-cached' \\`RET'
The above will save you from having to repeatedly type
your token or password, but you might still repeatedly
be asked for your username. To prevent that, change an
URL like
https://github.com/foo/bar.git
to
https://yourname@github.com/foo/bar.git
Instead of changing all such URLs manually, they can
be translated on the fly by doing this once
git config --global \
url.https://yourname@github.com.insteadOf \
https://github.com
[1]: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token."
(require 'auth-source)
(and (fboundp 'auth-source-search)
(string-match "\\`\\(.+\\)@\\([^@]+\\)\\'" key)
(let* ((user (match-str 1 key))
(host (match-str 2 key))
(secret
(plist-get
(car (or (auth-source-search :max 1 :host host :user user)
(auth-source-search :max 1 :host key)))
:secret)))
(if (functionp secret)
(funcall secret)
secret))))