[英]pygit2 clone_repository authentication required but no callback set
I'm trying to clone a repository from stash using an ssh link.我正在尝试使用 ssh 链接从 stash 克隆存储库。 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.RemoteCallbacks 并像这样调用它:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.