1

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?

hitochan
  • 1,028
  • 18
  • 34

1 Answers1

0

When talking to a remote hosting service, bad credentials will cause nodegit to reattempt your request. Depending on if you're on Windows or Mac that request will retry indefinitely or it will retry 5 times.

So I would guess that your OAuth credentials are incorrect and nodegit is retrying the request continuously.

Kyle S.
  • 147
  • 2
  • 9