Migrating BitBucket → Gitea via API, auth_token is not respected #6921

Closed
opened 2025-11-02 07:11:09 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @milichev on GitHub (Feb 24, 2021).

  • Gitea Version: 1.13.2
  • Git Version: 2.26.2, Wire Protocol Version 2 Enabled
  • Operating system: Docker Image gitea/gitea:1.13.2 (Alpine Linux v3.12)
  • Database (use [x]):
    • [x ] MySQL

Summary

Stuck with an auth problem migrating a repo from Bitbucket v7.2.3 to Gitea using API
It works great when I provide auth_username and auth_password.
But instead, I need to perform the API call with an auth_token which was added to a proper profile in the bitbucket server. I tried all possible values for service: git, bitbucket, github, gitlab...

API Call

curl -i -X POST \
   -H "Authorization:token 12321a991d89b636bf751a0f5071222eb7f97d2b" \
   -H "Content-Type:application/json" \
   -d \
'{
  "clone_addr": "https://the.company.com/scm/theteam/the-repo.git",
  "auth_token": "1233NzE0NTE4MDAxOsf2XC8H4sB5SylecNjlyh3glJKo",
  "description": "Migrate sample",
  "private": true,
  "repo_name": "the-server",
  "repo_owner": "theteam",
  "service": "git",
  "uid": 0,
  "issues": false,
  "labels": false,
  "milestones": false,
  "mirror": true,
  "pull_requests": false,
  "releases": false,
  "wiki": false
}' \
 'http://gitea:4000/api/v1/repos/migrate'

API Response

  • 422 Unprocessable Entity
{
  "message":"Authentication failed: Clone: exit status 128 - fatal: Authentication failed for 'https://the.company.com/scm/theteam/the-repo.git/'\n.",
  "url":"http://gitea:4000/api/swagger"
}

Gitea stdout

2021/02/24 19:45:13 Started POST /api/v1/repos/migrate for 10.1.0.1
[git-module] /usr/bin/git -c credential.helper= -c protocol.version=2 -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= clone --mirror --quiet -- https://oauth2:12321a991d89b636bf751a0f5071222eb7f97d2b@the.company.com/scm/theteam/the-repo.git /data/git/gitea-repositories/theteam/luft-repo.git
2021/02/24 19:45:14 ...i/v1/repo/migrate.go:183:func1() [E] DeleteRepository: repository does not exist [id: 3, uid: 1, owner_name: , name: ]
2021/02/24 19:45:14 Completed POST /api/v1/repos/migrate 422 Unprocessable Entity in 673.9368ms
Originally created by @milichev on GitHub (Feb 24, 2021). - Gitea Version: 1.13.2 - Git Version: 2.26.2, Wire Protocol Version 2 Enabled - Operating system: Docker Image `gitea/gitea:1.13.2` (Alpine Linux v3.12) - Database (use `[x]`): - [x ] MySQL ### Summary Stuck with an auth problem **migrating a repo from [Bitbucket v7.2.3](https://www.atlassian.com/software/bitbucket) to Gitea using API** It works great when I provide `auth_username` and `auth_password`. But instead, I need to perform the API call with an `auth_token` which was added to a proper profile in the bitbucket server. I tried all possible values for `service`: git, bitbucket, github, gitlab... ### API Call ```sh curl -i -X POST \ -H "Authorization:token 12321a991d89b636bf751a0f5071222eb7f97d2b" \ -H "Content-Type:application/json" \ -d \ '{ "clone_addr": "https://the.company.com/scm/theteam/the-repo.git", "auth_token": "1233NzE0NTE4MDAxOsf2XC8H4sB5SylecNjlyh3glJKo", "description": "Migrate sample", "private": true, "repo_name": "the-server", "repo_owner": "theteam", "service": "git", "uid": 0, "issues": false, "labels": false, "milestones": false, "mirror": true, "pull_requests": false, "releases": false, "wiki": false }' \ 'http://gitea:4000/api/v1/repos/migrate' ``` ### API Response - 422 Unprocessable Entity ```json { "message":"Authentication failed: Clone: exit status 128 - fatal: Authentication failed for 'https://the.company.com/scm/theteam/the-repo.git/'\n.", "url":"http://gitea:4000/api/swagger" } ``` ### Gitea `stdout` ``` 2021/02/24 19:45:13 Started POST /api/v1/repos/migrate for 10.1.0.1 [git-module] /usr/bin/git -c credential.helper= -c protocol.version=2 -c filter.lfs.required= -c filter.lfs.smudge= -c filter.lfs.clean= clone --mirror --quiet -- https://oauth2:12321a991d89b636bf751a0f5071222eb7f97d2b@the.company.com/scm/theteam/the-repo.git /data/git/gitea-repositories/theteam/luft-repo.git 2021/02/24 19:45:14 ...i/v1/repo/migrate.go:183:func1() [E] DeleteRepository: repository does not exist [id: 3, uid: 1, owner_name: , name: ] 2021/02/24 19:45:14 Completed POST /api/v1/repos/migrate 422 Unprocessable Entity in 673.9368ms ```
Author
Owner

@milichev commented on GitHub (Feb 24, 2021):

This one is fixed simply by providing the token in the auth_password along with auth_username field:

{
  "clone_addr": "https://the.company.com/scm/theteam/the-repo.git",
  "auth_username": "the.user",
  "auth_password": "1233NzE0NTE4MDAxOsf2XC8H4sB5SylecNjlyh3glJKo",
@milichev commented on GitHub (Feb 24, 2021): This one is fixed simply by providing the token in the `auth_password` along with `auth_username` field: ```json { "clone_addr": "https://the.company.com/scm/theteam/the-repo.git", "auth_username": "the.user", "auth_password": "1233NzE0NTE4MDAxOsf2XC8H4sB5SylecNjlyh3glJKo", ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6921