# Authentication failed for, but running the command again works?

**URL:** <https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521>\
**Category:** Gitea Usages\
**Created:** [February 1, 2024, 11:25pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521 "2024-02-01T23:25:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![No0Vad](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@No0Vad](https://forum.gitea.com/u/No0Vad)\
**Post date:** [February 1, 2024, 11:25pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/1 "2024-02-01T23:25:43Z")

</div>

Sometimes my authentication with git on Windows is lost? I guess it happens after x amount of time has passed.  
When it happens the command (fetch, pull, push etc) will fail with a error, but if I run the command immediately again it works.

![image](https://us1.discourse-cdn.com/flex020/uploads/gitea/original/2X/4/4e8363050fa06296f5a3592212d76d66ff7f9e1b.png)

How can I resolve this? I use HTTPS (not SSH) for communicating with Gitea.  
Is it a setting somewhere within Gitea or is this a Git issue?

---

<div class="post-metadata">

**Author:** ![No0Vad](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@No0Vad](https://forum.gitea.com/u/No0Vad)\
**Post date:** [February 9, 2024, 7:00pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/2 "2024-02-09T19:00:53Z")

</div>

I found this setting here [Config Cheat Sheet | Gitea Documentation](https://docs.gitea.com/administration/config-cheat-sheet#oauth2-oauth2)  
Increasing **ACCESS\_TOKEN\_EXPIRATION\_TIME** to 24 hours from 1 hour does improve it.  
It happens way less often now and it works for me.

---

<div class="post-metadata">

**Author:** ![marc6h](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/marc6h/32/5972_2.png) [@marc6h](https://forum.gitea.com/u/marc6h)\
**Post date:** [July 5, 2024, 9:46am UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/3 "2024-07-05T09:46:04Z")

</div>

I have exactly the same issue (and workaround). Just wondering what exactly is the cause, and if there is a proper solution.

---

<div class="post-metadata">

**Author:** ![Mario-Eis](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/mario-eis/32/6107_2.png) [@Mario-Eis](https://forum.gitea.com/u/Mario-Eis)\
**Post date:** [July 18, 2024, 12:10pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/4 "2024-07-18T12:10:41Z")

</div>

Same here. I guess it has something to do with the token refresh. Thats a pitty… I started to like gitea.

---

<div class="post-metadata">

**Author:** ![No0Vad](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@No0Vad](https://forum.gitea.com/u/No0Vad)\
**Post date:** [July 18, 2024, 12:34pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/5 "2024-07-18T12:34:16Z")

</div>

That is my guess as well, but since I’ve increase the value of **ACCESS\_TOKEN\_EXPIRATION\_TIME** it’s barely noticeable for me at least 😊  
And I really like Gitea and will continue to use it.

Sure it would be nice if the refresh worked without first failing. I don’t know where the “issue” lies, is it within Gitea or the app that Git for Windows uses that you authorize? 🤷

---

<div class="post-metadata">

**Author:** ![lunny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/lunny/32/4701_2.png) [@lunny](https://forum.gitea.com/u/lunny)\
**Post date:** [September 27, 2024, 8:06pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/6 "2024-09-27T20:06:29Z")

</div>

All these happened in Windows?

---

<div class="post-metadata">

**Author:** ![No0Vad](https://avatars.discourse-cdn.com/v4/letter/n/46a35a/32.png) [@No0Vad](https://forum.gitea.com/u/No0Vad)\
**Post date:** [September 27, 2024, 9:45pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/7 "2024-09-27T21:45:32Z")

</div>

For me, yes. I’m on Windows 11.

---

<div class="post-metadata">

**Author:** ![lunny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/lunny/32/4701_2.png) [@lunny](https://forum.gitea.com/u/lunny)\
**Post date:** [October 9, 2024, 5:10pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/8 "2024-10-09T17:10:33Z")

</div>

How about using [GitHub - hickford/git-credential-oauth: A Git credential helper that securely authenticates to GitHub, GitLab and BitBucket using OAuth.](https://github.com/hickford/git-credential-oauth)

---

<div class="post-metadata">

**Author:** ![fatotaku](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/fatotaku/32/6420_2.png) [@fatotaku](https://forum.gitea.com/u/fatotaku)\
**Post date:** [November 18, 2024, 7:04pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/9 "2024-11-18T19:04:17Z")

</div>

I also see this issue.  
Is there a solution to this, or a fix scheduled?  
Given it was reported 10 months ago, I’d expect it to at-least have been triaged.  
It’s annoying enough that I’m considering switching to Gitlab if it won’t be acknowledged/fixed.

Environment  
Gitea Server: Gitea Docker image, hosted on Debian  
Client: Git for windows via Visual Studio 2022 on Windows 11  
Using default authentication settings.

---

<div class="post-metadata">

**Author:** ![sao-coding](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/sao-coding/32/6546_2.png) [@sao-coding](https://forum.gitea.com/u/sao-coding)\
**Post date:** [January 6, 2025, 4:10pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/10 "2025-01-06T16:10:26Z")

</div>

Has this issue been resolved?

---

<div class="post-metadata">

**Author:** ![Ferd](https://avatars.discourse-cdn.com/v4/letter/f/58956e/32.png) [@Ferd](https://forum.gitea.com/u/Ferd)\
**Post date:** [January 13, 2025, 6:31am UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/11 "2025-01-13T06:31:12Z")

</div>

Same at my gitea installation (as fatotaku described it).  
Is this planned to be resolved?

---

<div class="post-metadata">

**Author:** ![Fred4711](https://avatars.discourse-cdn.com/v4/letter/f/22d042/32.png) [@Fred4711](https://forum.gitea.com/u/Fred4711)\
**Post date:** [February 18, 2025, 12:32pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/12 "2025-02-18T12:32:24Z")

</div>

is there any update, or Workaround ?

---

<div class="post-metadata">

**Author:** ![OCram85](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/ocram85/32/4947_2.png) [@OCram85](https://forum.gitea.com/u/OCram85)\
**Post date:** [March 4, 2025, 11:01am UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/13 "2025-03-04T11:01:27Z")

</div>

Again, same problem here in my instances with windows based git clients.

Any updates on this? 🙏

---

<div class="post-metadata">

**Author:** ![agardiol](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/agardiol/32/4163_2.png) [@agardiol](https://forum.gitea.com/u/agardiol)\
**Post date:** [April 10, 2025, 3:28pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/14 "2025-04-10T15:28:05Z")

</div>

Same issue for months now. Any update ?

---

<div class="post-metadata">

**Author:** ![marvint24](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/marvint24/32/6836_2.png) [@marvint24](https://forum.gitea.com/u/marvint24)\
**Post date:** [April 28, 2025, 7:47am UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/15 "2025-04-28T07:47:54Z")

</div>

Seems to be this issue on GitHub: [First authorization via OAUTH fails · Issue #31470 · go-gitea/gitea · GitHub](https://github.com/go-gitea/gitea/issues/31470)

---

<div class="post-metadata">

**Author:** ![lunny](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.gitea.com/lunny/32/4701_2.png) [@lunny](https://forum.gitea.com/u/lunny)\
**Post date:** [June 13, 2025, 7:56pm UTC](https://forum.gitea.com/t/authentication-failed-for-but-running-the-command-again-works/8521/16 "2025-06-13T19:56:31Z")

</div>

It’s an upstream problem and there is a pull request [fix(generic): check local token expiry by becm · Pull Request #1837 · git-ecosystem/git-credential-manager · GitHub](https://github.com/git-ecosystem/git-credential-manager/pull/1837) but not merged.
