You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document how to use personal access token in config file #286
The client tries to open the browser to authenticate the user. However this doesn't work if you are on a remote system via ssh. Can the user generate a Personal Access Token and use that?
Reacted by kiransiluveru777, wakebird and Aleksander Baranowski
I'm on Linux, I used git config --global credential.helper store and I can clone private repos without an access prompt. However gh still tries to open a browser to authenticate me.
@travi Not sure about the compatibility. I suggest creating a new issue and a dev will circle back in due time. Perhaps give it a whirl and include the results? Thanks for the interest in gh.
@pdxjohnny Not that we don't really support Personal Access Tokens, as some commands might not work with that type of authentication; most notably the gh pr status command will yield a cryptic error
graphql error: 'Field 'statusCheckRollup' doesn't exist on type 'Commit',
Field 'reviewDecision' doesn't exist on type 'PullRequest''
It's better to authenticate on a local machine using OAuth and then copy the resulting ~/.config/gh/config.yml file to the remote machine under SSH.
@travi We don't yet respect the netrc file, but we appreciate the suggestion!
@ggb667 Manually editing the config file is not something I'd recommend to most users, either. Generally, you can just run gh auth login and follow the browser-based authentication flow that's easy to perform on any platform. Alternatively, the same command will also accept a pasted Personal Access Token.
I didn't know that you could just use the PAT as the password and it would work. The prompt should say Password or Personal Access Token to make it clear.
Reacted by Pratik Gandhi, Bernard Marius 't Hart and Sal-LGBTCenters
For anyone still wondering about how to use their Personal Access Token with GitHub CLI, the answer is to never edit the config files directly. Their location and format might change over time (as it already has since then). The solution is to use the gh auth login command, which can either generate a token for you (by taking you through the browser authorization flow) or take an already generated token as input.
Reacted by Ryan Kulla, Brian Surowiec and Nathan Bendich
Activity
tierninho commentedon Jan 31, 2020
@pdxjohnny Thanks for the question.
Yes, please use HTTPS and a person access token. If you need instructions for setting up the token, go here: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
Let us know how it goes.
johnandersen777 commentedon Jan 31, 2020
Where do I put the token, Is there a config file somewhere?
tierninho commentedon Jan 31, 2020
Hopefully, this clarifies it: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line#using-a-token-on-the-command-line
Once you clone a repo, it will be recognized and should be cached in your keychain. Next step would be to try to install
GHagain https://github.com/cli/cli#installation.johnandersen777 commentedon Jan 31, 2020
I'm on Linux, I used
git config --global credential.helper storeand I can clone private repos without an access prompt. However gh still tries to open a browser to authenticate me.johnandersen777 commentedon Jan 31, 2020
tierninho commentedon Jan 31, 2020
Ah, great! Not too familiar with Linux! Cheers.
[-]Can't authenticate without browser[/-][+]Document how to use personal access token in config file[/+]johnandersen777 commentedon Jan 31, 2020
It might be good to add this to the docs
travi commentedon Jan 31, 2020
is this tool compatible with a
.netrcfile?tierninho commentedon Jan 31, 2020
Absolutely, just created an issue! #287
tierninho commentedon Jan 31, 2020
@travi Not sure about the compatibility. I suggest creating a new issue and a dev will circle back in due time. Perhaps give it a whirl and include the results? Thanks for the interest in
gh.mislav commentedon Feb 1, 2020
@pdxjohnny Not that we don't really support Personal Access Tokens, as some commands might not work with that type of authentication; most notably the
gh pr statuscommand will yield a cryptic errorIt's better to authenticate on a local machine using OAuth and then copy the resulting
~/.config/gh/config.ymlfile to the remote machine under SSH.@travi We don't yet respect the netrc file, but we appreciate the suggestion!
johnandersen777 commentedon Feb 1, 2020
@mislav Thank you! Great idea
ggb667 commentedon Oct 18, 2021
This [editing files] is horribly compex.
< strikethrough >I'm on windows, no one knows or wants this. Just put passwords back.<\strikethrough>
mislav commentedon Oct 19, 2021
@ggb667 Manually editing the config file is not something I'd recommend to most users, either. Generally, you can just run
gh auth loginand follow the browser-based authentication flow that's easy to perform on any platform. Alternatively, the same command will also accept a pasted Personal Access Token.ggb667 commentedon Nov 6, 2021
I didn't know that you could just use the PAT as the password and it would work. The prompt should say Password or Personal Access Token to make it clear.
rkulla commentedon Dec 7, 2021
For anyone stumbling across this PR still via google, the
github:section should go in hosts.yml not config.yml or you will probably get errors.mislav commentedon Dec 7, 2021
For anyone still wondering about how to use their Personal Access Token with GitHub CLI, the answer is to never edit the config files directly. Their location and format might change over time (as it already has since then). The solution is to use the
gh auth logincommand, which can either generate a token for you (by taking you through the browser authorization flow) or take an already generated token as input.chore: refactor tracer (cli#286)