I'm trying to clone a repository from stash using an ssh link. I get an error saying authentication is required, This should not require a username and password. How do I fix this error?
from pygit2 import *
repo_name = "ssh://git@stash:TheProject"
clone_repository(self.repo_name, self.repo_dir, credentials=cred)
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__ return self.func(*args)
File "rio_telem_tool.py", line 143, in build clone_repository(self.repo_name, self.repo_dir)
File "/usr/local/lib/python2.7/dist-packages/pygit2/__init__.py", line 265, in clone_repository check_error(err)
File "/usr/local/lib/python2.7/dist-packages/pygit2/errors.py", line 56, in check_error raise GitError(message)
GitError: authentication required but no callback set
This is an old question, but I recently had two issues to solve:
The solution to both involved subclassing pygit2.RemoteCallbacks and calling it like this:
pygit2.clone_repository(your_args, callbacks=self.MyRemoteCallBacks(user,token)
The class:
class MyRemoteCallbacks(pygit2.RemoteCallbacks):
def __init__(self, user, token):
self.user = user
self.token = token
def credentials(self, url, username_from_url, allowed_types):
return pygit2.UserPass(self.user,self.token)
def certificate_check(self, certificate, valid, host):
return True
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.