use `gh` CLI to get OAuth token
There are a few ways that the gh CLI represents a token, including via an environment variable GH_TOKEN
In my development environment
gh auth status --show-token
displays the the token.
However:
$ git-spr --version
> git rev-parse --show-toplevel
4:48PM WRN ../../Users/runner/work/spr/spr/github/githubclient/client.go:89 > failed to read gh cli config file error="failed to open gh cli config file: open /home/ggoretkin/.config/gh/hosts.yml: no such file or directory"
4:48PM WRN ../../Users/runner/work/spr/spr/github/githubclient/client.go:101 > failed to read hub config file error="failed to open hub config file: open /home/ggoretkin/.config/hub: no such file or directory"
No GitHub OAuth token found! You can either create one
at https://github.com/settings/tokens and set the GITHUB_TOKEN environment variable,
or use the official "gh" CLI (https://cli.github.com) config to log in:
$ gh auth login
Alternatively, configure a token manually in ~/.config/hub:
github.com:
- user: <your username>
oauth_token: <your token>
protocol: https
This configuration file is shared with GitHub's "hub" CLI (https://hub.github.com/),
so if you already use that, spr will automatically pick up your token.
Note that as of https://github.com/cli/cli/releases/tag/v2.24.0 , the hosts.yml file is not used anymore.
new user here, I'm confused by this as well, I did gh auth login however git spr status still says no token found
I've tried to configure manually token in ~/.config/hub by adding token from https://github.com/settings/tokens and gh auth status --show-token but both doesn't seem to work. how to configure this ?
update: storing the token in GH_TOKEN works
I am trying to connect to our Github Enterprise server, and observe the same behaviour: Logged in fine when using gh auth status, but spr does not pick it up. I am unable to set up ~/.config/hub such that it would show any effect – perhaps the message here is not correct?
Setting the token in GITHUB_TOKEN as suggested in the help message works fine. (Not the one mentioned by @eko-wibowo.)
TL;DR: gh auth login --insecure-storage let's you use gh as the source of the OAuth token.
For anyone struggling with this, spr tries to get the OAuth token from three sources:
-
Environment variable
GITHUB_TOKEN - ~/.config/gh/hosts.yml
- ~/.config/hub
After gh release v2.26.0 logging in using gh auth login will no longer store the OAuth token as plain-text unless the --insecure-storage parameter is passed.
Hello everyone,
First off, I'd like to say that this tool is fantastic—great work!
I have a question regarding the selection options for scopes. Specifically, how many options should I select to appropriately define the access level for personal tokens?
Thank you for your assistance!