I want to clone a private repository using nodegit, a npm package. I followed a guides for cloning private repository and set the clone options as fllows,
cloneOptions:
remoteCallbacks:
certificateCheck: ()-> return 1
credentials: ()->
return NodeGit.Cred.userpassPlaintextNew(GITHUB_TOKEN, "x-oauth-basic")
but I got an error saying,"authentication required but no callback set"
. So I checked some of the related source code of nodegit
and set cloneOptions
as follows,
cloneOptions =
fetchOpts:
callbacks:
certificateCheck: ()-> return 1 # For OS X issue with GitHub certificate
credentials: ()->
cred = NodeGit.Cred.userpassPlaintextNew(GITHUB_TOKEN, "x-auth-basic")
return cred
The behavior of this code is somewhat strange because it seems to clone the repository but cloneOpts.fetchOpts.callbacks.credential()
is called repeatedly and the program doesn't stop running.
If I instead use username and password as arguments for git.Cred.userpassPlaintextNew
, credentials()
is called only once (which is the expected behavior) and the repository is cloned.
Can anyone give me some hints on what is wrong with my codes?