Open hickford opened 1 year ago
dnf search git-credential
get
command, some more documentation on that would be appreciated@kra-mo The get
command is called by Git. The only command you need to run manually is git credential-oauth configure
.
I'll try to make this clearer.
Thank you for your work on this!
@gzzchh Thanks.
close browser tab when authorize success
I'd like that, but AFAIK it's not technically possible because "Scripts may not close windows that were not opened by script" https://developer.mozilla.org/en-US/docs/Web/API/Window/close
Follow the code generate by ChatGPT. closing window is OK.
html := `
<html>
<head>
<script>
setTimeout(function() {
window.close();
}, 2000);
</script>
</head>
<body>
Success. You may close this page and return to Git.
</body>
</html>
`
w.Write([]byte(html))
@Christoph-Raab Thanks for your response.
autorefresh tokens in the background
Are you having to reauthenticate regularly in browser? What's your helper setup git config --get-all credential.helper
? If you are using cache, try setting a longer timeout such as cache --timeout 72000
(20 hours).
I regular have to retry on a push or fetch
remote: HTTP Basic: Access denied. The provided password or token is incorrect or your account has 2FA enabled and you must use a personal access token instead of a password. See
https://<gitlab-host>/help/topics/git/troubleshooting_git#error-on-git-fetch-http-basic-access-denied
git config --get-all credential.helper
doesn't return anything, but my git config looks like this
[credential "<gitlab-host>"]
oauthClientId = <some id>
oauthClientSecret = <some secret>
oauthScopes = read_repository write_repository
oauthAuthURL = /oauth/authorize
oauthTokenURL = /oauth/token
helper = cache --timeout 36000
helper = oauth
I regularly have to retry on a push or fetch
Sounds like Git is trying to use expired OAuth tokens. @Christoph-Raab Which version of Git are you using (git --version
)? credential-cache has support for password_expiry_utc attribute from 2.40 and oauth_refresh_token attribute from 2.41 (https://github.com/hickford/git-credential-oauth/issues/20) .
I'm on 2.34.1. I can try to update and check if that fixes the issue.
cache --timeout 36000
cache --timeout 7200 \n oauth
go get ...
to authenticate to a private https-only git repository (where I don't think I actually needed this; disabling GOSUMDB for my domain was the solution).osxkeychain
cache --timeout 10400
oauth
plus
[credential "https://gitea...."]
helper = oauth
oauthClientId = a386d92d-2983-....
oauthScopes = read_repository
oauthAuthURL = /login/oauth/authorize
oauthTokenURL = /login/oauth/access_token
How did you discover git-credential-oauth?
Searched, because it's 2024 and Git on Linux still doesn't have password storage by default
How did you install git-credential-oauth?
deb package, then uninstalled as it pulled in most of an XServer, then realised it wouldn't work for me as it's a remote box and I'm not SSH forwarding
Do you authenticate to any Git hosts outside GitHub?
Yes
What's your credential.helper configuration? Run git config --get-all credential.helper to check.
Nothing, on this box, apparently.
"manager" on Windows.
What problem did git-credential-Oauth solve for you?
None yet.
Any ideas for improvements?
I don't know - without CLI-only OAuth working this won't work for me
@voltagex
deb package pulled in most of an XServer
Debian package git-credential-oauth has no strict dependencies, though it recommends package xdg-open. You can avoid installing it with apt install --no-install-recommends git-credential-oauth
.
it wouldn't work for me as it's a remote box
Have you tried helper = oauth -device
(v0.11.0 or later)? This works on any system including browserless systems. https://github.com/hickford/git-credential-oauth/blob/main/README.md#browserless-systems
Thanks for your help @hickford
I am able to use it on my box that has a UI and a web browser, but -device
with Forgejo leads to endpoint missing DeviceAuthURL
which I believe needs some changes from Forgejo itself.
1. How did you discover git-credential-oauth?
apt search git credential
/ Stack Overflow
- How did you install git-credential-oauth?
apt
- Do you authenticate to any Git hosts outside GitHub?
6. Any ideas for improvements?
pls support more “indie” platforms like the ones above
Have you tried
helper = oauth -device
(v0.11.0 or later)? This works on any system including browserless systems. https://github.com/hickford/git-credential-oauth/blob/main/README.md#browserless-systems
GitHub kept giving me a link that would redirect back to 127.0.0.1:37653
after logging in from a browser. I had to setup a SSH tunnel to set it up on my hetzner box (ssh -i -L 127.0.0.1:37653:127.0.0.1:37653 hetzner
). It did work as advertised when I was setting it up on my local machine.
System details OS: nixOS 24.05 Version: 0.11.3
Git config
[credential]
helper = "/nix/store/xl2hmm62sbjfm574car3a8ac45y83qik-git-credential-oauth-0.11.3/bin/git-credential-oauth"
helper = "cache --timeout 120"
helper = "oauth -device"
git credential-oauth configure
) My credential.helper on bare metal Linux:
/usr/share/doc/git/contrib/credential/libsecret/git-credential-libsecret
oauth
My credential.helper on WSL:
cache --timeout 21600
oauth
- How did you discover git-credential-oauth?
I was working on a private GitHub repository where I needed my local computer's bare git to authenticate to GitHub using OAuth. (The project did not want to issue personal access tokens or use ssh.) GitHub's git cli instructions recommended using Git Credential Manager, installing via Homebrew. I use MacPorts and not Homebrew, so I searched MacPorts for a git credential helper supporting oauth. I found this.
- How did you install git-credential-oauth?
Using MacPorts and its git-credential-oauth port.
- Do you authenticate to any Git hosts outside GitHub?
No. And not GitHub yet! I am having difficulty.
- What's your credential.helper configuration? Run git config --get-all credential.helper to check.
% git config --get-all credential.helper
osxkeychain
oauth -verbose
- What problem did git-credential-Oauth solve for you?
I hope that it will let me work with a private repo on GitHub.
- Any ideas for improvements?
Better diagnostics for my failure case.
cache --timeout 21600
oauth
Hi users. A quick survey:
git config --get-all credential.helper
to check.