Fix private GitHub mirroring auth payload for Gitea/Forgejo migrate API.
Replace GitLab-style auth_username: "oauth2" assumption with GitHub-compatible source credentials.
Add shared helper to construct private-source auth fields consistently across both mirror code paths.
Add unit tests for credential payload selection and validation.
Root Cause
A previous Forgejo 12 compatibility refactor removed credentials from clone URLs (correct), but switched private GitHub source auth to auth_username + auth_token with auth_username="oauth2".
That username pattern is not reliably valid for GitHub HTTPS auth and caused private clone failures (Invalid username or token, could not read Username ... terminal prompts disabled).
What Changed
src/lib/gitea.ts
mirrorGithubRepoToGitea: use buildGithubSourceAuthPayload(...) for private sources.
mirrorGitHubRepoToGiteaOrg: use the same helper for org mirror path.
src/lib/utils/mirror-source-auth.ts
New helper building auth_username, auth_password, and auth_token from GitHub config/repo context.
src/lib/utils/mirror-source-auth.test.ts
New tests covering owner/username/repo-owner fallback order, token trimming, and missing token error.
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.
📋 Pull Request Information
Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/255
Author: @arunavo4
Created: 3/27/2026
Status: ✅ Merged
Merged: 3/27/2026
Merged by: @arunavo4
Base:
main← Head:codex/fix-issue-254-private-mirror-auth📝 Commits (1)
df2d9a2fix private github mirror auth📊 Changes
3 files changed (+142 additions, -16 deletions)
View changed files
📝
src/lib/gitea.ts(+33 -16)➕
src/lib/utils/mirror-source-auth.test.ts(+63 -0)➕
src/lib/utils/mirror-source-auth.ts(+46 -0)📄 Description
Summary
auth_username: "oauth2"assumption with GitHub-compatible source credentials.Root Cause
A previous Forgejo 12 compatibility refactor removed credentials from clone URLs (correct), but switched private GitHub source auth to
auth_username + auth_tokenwithauth_username="oauth2".That username pattern is not reliably valid for GitHub HTTPS auth and caused private clone failures (
Invalid username or token,could not read Username ... terminal prompts disabled).What Changed
src/lib/gitea.tsmirrorGithubRepoToGitea: usebuildGithubSourceAuthPayload(...)for private sources.mirrorGitHubRepoToGiteaOrg: use the same helper for org mirror path.src/lib/utils/mirror-source-auth.tsauth_username,auth_password, andauth_tokenfrom GitHub config/repo context.src/lib/utils/mirror-source-auth.test.tsTesting
bun test src/lib/utils/mirror-source-auth.test.tsbun test src/lib/gitea.test.tsCloses #254
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.