libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.58k stars 382 forks source link

pygit2.GitError: failed to parse supported auth schemes: The operation identifier is not valid. #1225

Open PranjaliParnerkar opened 12 months ago

PranjaliParnerkar commented 12 months ago

I am trying to clone private github repository using pygit2 module but getting the below error.

Traceback (most recent call last):
  File ".\test2.py", line 29, in <module>
    repoClone = pygit2.clone_repository(repo_from_template.clone_url, 'C://TestRepo', callbacks=callbacks)
  File "C:\Anaconda3\lib\site-packages\pygit2\__init__.py", line 222, in clone_repository
    payload.check_error(err)
  File "C:\Anaconda3\lib\site-packages\pygit2\callbacks.py", line 93, in check_error
    check_error(error_code)
  File "C:\Anaconda3\lib\site-packages\pygit2\errors.py", line 65, in check_error
    raise GitError(message)
_pygit2.GitError: failed to parse supported auth schemes: The operation identifier is not valid.

Below is the source code I am using

import pygit2
import config_
from github import Github

g = Github(<personal access token>,base_url='https://api.github.com')
github_user = g.get_user()
org = g.get_organization(<org-name>)

repo_from_template=org.create_repo(name='TestRepo',private=True)

credentials = pygit2.UserPass(github_user.login, <personal access token>)
callbacks = pygit2.RemoteCallbacks(credentials=credentials)
repoClone = pygit2.clone_repository(repo_from_template.clone_url, 'C://TestRepo', callbacks=callbacks)

I am using python 3.9 and have tried pygit2 version 1.10.1 and 1.12.0 and both are giving the same error. Are there any changes made to the callbacks recently which is creating this issue?

accodev commented 12 months ago

I have the same issue

accodev commented 11 months ago

I worked around the problem recompiling libgit2 to use Schannel instead of WinHTTP and now it works. Sadly we have to patch it manually since there's no pygit2 distribution for windows with libgit2 compiled with Schannel.

GeorgeTTD commented 10 months ago

@accodev do you have an example of how you switch them over?

accodev commented 10 months ago

The process is pretty straight forward, but I strongly advise against using this in production:

You can either use cmake --install (with a correct --prefix) or copy the git2.dll manually to where pygit2 is installed, e.g.: C:\Users\<your_user>\AppData\Local\Programs\Python\Python311\Lib\site-packages\pygit2