mirror of
https://github.com/go-gitea/gitea.git
synced 2026-03-11 17:46:29 -05:00
First authorization via OAUTH fails #13195
Open
opened 2025-11-02 10:34:27 -06:00 by GiteaMirror
·
22 comments
No Branch/Tag Specified
main
release/v1.25
release/v1.24
release/v1.23
release/v1.22
release/v1.21
release/v1.20
release/v1.19
release/v1.18
release/v1.17
release/v1.16
release/v1.15
release/v1.14
release/v1.13
release/v1.12
release/v1.11
release/v1.10
release/v1.9
release/v1.8
v1.25.3
v1.25.2
v1.25.1
v1.25.0
v1.24.7
v1.25.0-rc0
v1.26.0-dev
v1.24.6
v1.24.5
v1.24.4
v1.24.3
v1.24.2
v1.24.1
v1.24.0
v1.23.8
v1.24.0-rc0
v1.25.0-dev
v1.23.7
v1.23.6
v1.23.5
v1.23.4
v1.23.3
v1.23.2
v1.23.1
v1.23.0
v1.23.0-rc0
v1.24.0-dev
v1.22.6
v1.22.5
v1.22.4
v1.22.3
v1.22.2
v1.22.1
v1.22.0
v1.23.0-dev
v1.22.0-rc1
v1.21.11
v1.22.0-rc0
v1.21.10
v1.21.9
v1.21.8
v1.21.7
v1.21.6
v1.21.5
v1.21.4
v1.21.3
v1.21.2
v1.20.6
v1.21.1
v1.21.0
v1.21.0-rc2
v1.21.0-rc1
v1.20.5
v1.22.0-dev
v1.21.0-rc0
v1.20.4
v1.20.3
v1.20.2
v1.20.1
v1.20.0
v1.19.4
v1.21.0-dev
v1.20.0-rc2
v1.20.0-rc1
v1.20.0-rc0
v1.19.3
v1.19.2
v1.19.1
v1.19.0
v1.19.0-rc1
v1.20.0-dev
v1.19.0-rc0
v1.18.5
v1.18.4
v1.18.3
v1.18.2
v1.18.1
v1.18.0
v1.17.4
v1.18.0-rc1
v1.19.0-dev
v1.18.0-rc0
v1.17.3
v1.17.2
v1.17.1
v1.17.0
v1.17.0-rc2
v1.16.9
v1.17.0-rc1
v1.18.0-dev
v1.16.8
v1.16.7
v1.16.6
v1.16.5
v1.16.4
v1.16.3
v1.16.2
v1.16.1
v1.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v1.3.2
v1.3.1
v1.3.0
v1.3.0-rc2
v1.3.0-rc1
v1.2.3
v1.2.2
v1.2.1
v1.2.0
v1.2.0-rc3
v1.2.0-rc2
v1.1.4
v1.2.0-rc1
v1.1.3
v1.1.2
v1.1.1
v1.1.0
v1.0.2
v1.0.1
v1.0.0
v0.9.99
Labels
Clear labels
$20
$250
$50
$500
backport/done
💎 Bounty
docs-update-needed
good first issue
hacktoberfest
issue/bounty
issue/confirmed
issue/critical
issue/duplicate
issue/needs-feedback
issue/not-a-bug
issue/regression
issue/stale
issue/workaround
lgtm/need 2
modifies/api
modifies/translation
outdated/backport/v1.18
outdated/theme/markdown
outdated/theme/timetracker
performance/bigrepo
performance/cpu
performance/memory
performance/speed
pr/breaking
proposal/accepted
proposal/rejected
pr/wip
pull-request
reviewed/wontfix
💰 Rewarded
skip-changelog
status/blocked
topic/accessibility
topic/api
topic/authentication
topic/build
topic/code-linting
topic/commit-signing
topic/content-rendering
topic/deployment
topic/distribution
topic/federation
topic/gitea-actions
topic/issues
topic/lfs
topic/mobile
topic/moderation
topic/packages
topic/pr
topic/projects
topic/repo
topic/repo-migration
topic/security
topic/theme
topic/ui
topic/ui-interaction
topic/ux
topic/webhooks
topic/wiki
type/bug
type/deprecation
type/docs
type/enhancement
type/feature
type/miscellaneous
type/proposal
type/question
type/refactoring
type/summary
type/testing
type/upstream
Mirrored from GitHub Pull Request
Milestone
No items
No Milestone
Projects
Clear projects
No project
No Assignees
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/gitea#13195
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Remmert-PBE on GitHub (Jun 24, 2024).
Description
The first authorization attempt after some hours fails, while the second one directly afterwards succeeds:
The gitea logfile shows that it tries to login with the user "OAUTH_USER" to our LDAP server, like it is saved by the Git Credential Manager:

The authorization after the initial error works for a few hours, but after a while it reappears (token becomes invalid?).
The credential settings in git are:
Gitea Version
1.21.11
Can you reproduce the bug on the Gitea demo site?
No
Log Gist
https://gist.github.com/Remmert-PBE/959e1e243a2d8243a757aef754571270
Screenshots
No response
Git Version
git version 2.45.2.windows.1
Operating System
Windows Server 2019 Standard
How are you running Gitea?
Running as a service on a windows server. Behind a nginx reverse proxy (configured like the example in the gitea docs)
Database
MSSQL
@Xulunix commented on GitHub (Jun 25, 2024):
I noticed the same issue using a similar setup (OIDC instead of LDAP).
It works if tried again but some tools check the remote periodically and ask the user to login again if authentication fails.
@yp05327 commented on GitHub (Jun 27, 2024):
It seems that this issue is similar to #30991?
Maybe
OAUTH_USERcomes from here:e124b8bb8f/src/shared/Core/GenericOAuthConfig.cs (L143)@yp05327 commented on GitHub (Jun 27, 2024):
I found a related issue ( maybe ) in GCM:
https://github.com/git-ecosystem/git-credential-manager/issues/1408
Maybe this is a problem from upstream (not directly related) ?
@Remmert-PBE commented on GitHub (Jun 27, 2024):
@yp05327 Good find, thats exactly what happens on my system. I ran a GCM_TRACE a few days back and it is similar to the one in the gcm issue. In my log the first push ends with the command erase and only on the 2nd push a new token is saved.
See https://gist.github.com/Remmert-PBE/1ccecd8d82c4b19d700835bff1b3567b
Now the question is, which tool is at fault?
@meruiden commented on GitHub (Jul 13, 2024):
I have the same, after a little while, when I push again, the first time always fails, second time succeeds. im also logged in via the vscode -> oauth in browser
@uujwnqjgim commented on GitHub (Aug 9, 2024):
First push fails with:
remote: Verify
fatal: Authentication failed for ...
second git push is ok
@257er commented on GitHub (Aug 30, 2024):
same issue here.
@eeyrjmr commented on GitHub (Sep 10, 2024):
same, this only just started to be an issue
@eeyrjmr commented on GitHub (Sep 11, 2024):
I can't be sure but I think this started when I stopped using the gogit build of gitea... This was partially due to sha256
I will see if gogit windows build still works
@jonathanduke commented on GitHub (Sep 12, 2024):
The same thing has been happening to me recently. Since some of my pulls/pushes are automated to happen at night, it's a real pain.
I think it started after upgrading git-for-windows to 2.45.2.windows.1 and switching to GCM. A workaround has been discussed in the forums here:
https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521
That does work to make it occur less often throughout the day if I set it to 24 hours vs. 1 hour, but it will still expire eventually. So, before my automated processes, I just made sure that I do an extra "git push" to force that expired token to be deleted, so the rest of the batch still works. That seems to get around the problem for now.
@lyleubben commented on GitHub (Sep 26, 2024):
Can confirm the same issue using git manually. Works on the second call. I believe this is also causing actions to fail on the checkout step.
@vansanper commented on GitHub (Oct 2, 2024):
Same issue here for my team, tried the workaround to see if it at least mitigates the problem to once a day...
@bvandevliet commented on GitHub (Dec 9, 2024):
I also still face this issue. Quite annoying tbh.
@seepine commented on GitHub (Jan 22, 2025):
I want to know if there are any good solutions at present, such as rolling back the git-for-windows version? Or rolling back the gitea version?
@eeyrjmr commented on GitHub (Jan 22, 2025):
It would be rolling back git-for-windows to the version that used a windows specific solution.
This is extremely frustrating but we are dependant on git-for-windows to fix. There are several open issues on this over at that repository, using different forges
@Remmert-PBE commented on GitHub (Jan 23, 2025):
I got it working by prepending the username to the remote url, i.e.
https://USER@git.company.intern/Organization/Product.git/. This prevents GCM from saving the login token with the dummy username 'OAUTH_USER'.@becm commented on GitHub (Feb 6, 2025):
It's a GCM issue, when it arbitrarily started to enforce OAuth when assuming a Gitea remote.
The issue is that token expiration dates are (still) not saved, so there is currently no other way than try and fail.
While other specialized providers for (e.g.) Azure and Bitbucket have some builtin
wayshacks to check this internally, there is no extra handling for the generic case.Mitigations boil down to
credential.oauthAuthorizeEndpoint=//(not viable with 2FA) orgit:https://<server>password entry with an application token(no expiry issue and better access restriction)
@wantong commented on GitHub (Apr 3, 2025):
i am facing the same issue, as enable LDAP auth for gitea, my users need to push twice to get checkin work done. is there any progress one this problem?
@seepine commented on GitHub (Apr 11, 2025):
Change
app.iniexpiration time can help me, although it's not the ultimate solution.https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/2
@becm commented on GitHub (Apr 27, 2025):
Expiry detection for JWT credentials (as used by Gitea) might actually be fairly trivial:
But the GCM project seems to be (currently) unmaintained, fixes and improvements are not processed.
Only thing possible on the Gitea side would be to further improve the (original)
remote: Verifymessage.@w3ori commented on GitHub (Jun 20, 2025):
Same issue with LDAP.
@zc-devs commented on GitHub (Oct 7, 2025):
https://github.com/go-gitea/gitea/issues/31470#issuecomment-2641395661:
Control Panel\All Control Panel Items\Credential ManagerWindows CredentialsEditOAUTH_USERto yourmynameand set the token from step 1 in thepasswordfield.