Skip to content

Instantly share code, notes, and snippets.

@vital101
Created September 26, 2016 10:36
Show Gist options
  • Save vital101/28f534d6e26d71afe547855533a01d66 to your computer and use it in GitHub Desktop.
Save vital101/28f534d6e26d71afe547855533a01d66 to your computer and use it in GitHub Desktop.
NodeGit Clone Private with Token
const repo = 'vital101/kernl-example-plugin-gitub';
const token = 'my-token-from-oauth';
const cloneURL = `https://${token}:[email protected]/${repository}`;
const cloneOptions = {
fetchOpts: {
callbacks: {
certificateCheck: () => { return 1; },
credentials: () => {
return NodeGit.Cred.userpassPlaintextNew(token, 'x-oauth-basic');
}
}
};
const cloneRepository = NodeGit.Clone(cloneURL, '/path/to/clone/in/to', cloneOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment