Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
PranjaliParnerkar opened this issue Jul 7, 2023 · 4 comments

Comments

@PranjaliParnerkar
Copy link

PranjaliParnerkar commented Jul 7, 2023

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
Copy link

accodev commented Jul 7, 2023

I have the same issue

@accodev
Copy link

accodev commented Jul 13, 2023

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
Copy link

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

@accodev
Copy link

accodev commented Aug 18, 2023

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

  • Clone the libgit2 repo: https://github.com/libgit2/libgit2
  • Open up a Visual Studio Developer command prompt (I used VS2022 Community Edition) and change directory to where the project was cloned
$ mkdir build && cd build
$ cmake .. -DUSE_HTTPS=Schannel
$ cmake --build . --config Release
$ cmake --install . --config Release --prefix /path/to/your/pygit2/installation

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants