Next: Setup for Another Github Instance, Up: Initial Setup [Contents][Index]
First inform Forge about your https://github.com username:
git config --global github.user USERNAME
If you need to identify as another user in a particular repository, then you have to set that variable locally:
cd /path/to/repo git config --local github.user USERNAME
Visit https://github.com/settings/tokens in a browser to generate
a new "classic" token using the repo
, user
and read:org
scopes.
Do not close the browser window just yet, because the token will
only be shown once.
The built-in Auth-Source ((auth)Top) package is used to store the
token generated in the previous step. The auth-sources
variable
controls how and where Auth-Source keeps its secrets. The default
value is a list of three files: ("~/.authinfo" "~/.authinfo.gpg"
"~/.netrc")
, but that can lead to confusing behavior, so you should
make sure that only one of these files exists, and then you should
also adjust the value of the variable to only ever use that file,
for example:
(setq auth-sources '("~/.authinfo"))
In ~/.authinfo
secrets are stored in plain text. If you don’t want
that, then you should use the encrypted ~/.authinfo.gpg
instead:
(setq auth-sources '("~/.authinfo.gpg"))
Make sure you put one of these forms in your init file and to evaluate
it in the current Emacs instance as well, by placing the cursor after
the final closing parenthesis and typing C-x C-e
(eval-last-sexp
).
Next add a line like the following to the chosen file:
machine api.github.com login USERNAME^forge password TOKEN
machine
must be api.github.com
. Variations of this
won’t work.
github.user
Git
variable above. You must append ^forge
to that, without any space
in between.
Finish by typing M-x auth-source-forget-all-cached RET
. If you don’t
do this, then Auth-Source may fail to look up the token.
Next: Setup for Another Github Instance, Up: Initial Setup [Contents][Index]