Pygit2 cannot parse URLs with OAuth tokens.
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.7k
- Forks
- 408
- Avg merge
- 2d 57m
- Merged PRs (30d)
- 7
Description
I'm trying to use pygit2 to clone a GitHub repo using OAuth tokens.
This actually works well from the command line, as explained on GitHub's blog here.
So, I do:
from pygit2 import clone_repository
oauth_token = 'somesuperlongtokengivenbygithub'
repo = clone_repository(
'https://'+oauth_token+'@github.com/openwrt/luci',
'/tmp/repos',
bare=True
)
and I get back:
00:04:42 _pygit2.GitError: Unsupported URL protocol
Traceback (most recent call last):
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/worker.py", line 558, in perform_job
rv = job.perform()
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/job.py", line 495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/home/ubuntu/repo/etincelle/routes.py", line 41, in clone_all_repos
clone(repo, _app, token)
File "/home/ubuntu/repo/etincelle/routes.py", line 25, in clone
clone_repository(oauth_url, git_id_repo, bare=True)
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/__init__.py", line 293, in clone_repository
check_error(err)
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/errors.py", line 64, in check_error
raise GitError(message)
_pygit2.GitError: Unsupported URL protocol
Traceback (most recent call last):
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/worker.py", line 558, in perform_job
rv = job.perform()
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/rq/job.py", line 495, in perform
self._result = self.func(*self.args, **self.kwargs)
File "/home/ubuntu/repo/etincelle/routes.py", line 41, in clone_all_repos
clone(repo, _app, token)
File "/home/ubuntu/repo/etincelle/routes.py", line 25, in clone
clone_repository(oauth_url, git_id_repo, bare=True)
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/__init__.py", line 293, in clone_repository
check_error(err)
File "/home/ubuntu/.venv/etincelle/lib/python3.4/site-packages/pygit2/errors.py", line 64, in check_error
raise GitError(message)
_pygit2.GitError: Unsupported URL protocol
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the clone_repository call shown in pygit2/init.py and inspect how the URL reaches the error check in errors.py. Reproduce the OAuth-token URL case, compare it with the command-line behavior described in the issue, and determine what existing URL or authentication handling applies. Done means clone_repository accepts the documented GitHub token URL without raising Unsupported URL protocol.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100