Nodegit: can i use [Personal Access Tokens] with userpassPlaintextNew

Created on 25 Jan 2018  路  5Comments  路  Source: nodegit/nodegit

const Git = require("nodegit");
const conf = require('../config')

var opts = {
    fetchOpts: {
        callbacks: {
            credentials: function () {
                // works
               return Git.Cred.userpassPlaintextNew(conf.account, conf.password)
                //doesn't work
                return Git.Cred.sshKeyNew( conf.myTokens, "x-oauth-basic");
            },
            certificateCheck: function () {
                return 1;
            }
        }
    }
};
function cloneGit (){
    Git.Clone(conf.cur_git_path, "test",opts)
    .then((repo) => {
        console.log('repo done, repo.workdir', repo);
    })
    .catch((e) => {
        console.log(e);
    });
}

http://www.nodegit.org/api/cred/#userpassPlaintextNew
has nothing about Personal Access Tokens

thanks ~~

Most helpful comment

i've tried this, but there is a warning "Error: request failed with status code: 401 errno: -1"
have more descriptions about this method?

All 5 comments

Maybe this example will help.

i've tried this, but there is a warning "Error: request failed with status code: 401 errno: -1"
have more descriptions about this method?

i tried like this, it's ok!

Git.Cred.sshKeyNew( conf.account, conf.myTokens);

https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/#using-a-token-on-the-command-line

would like to bump this, because this still seems to be an issue. I can't really get this working with an access token

nevermind, my issue seemed to be related to the scope of the token

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThePlenkov picture ThePlenkov  路  7Comments

monkeyboy64 picture monkeyboy64  路  7Comments

Yezior picture Yezior  路  8Comments

feifeipan picture feifeipan  路  5Comments

mklueh picture mklueh  路  5Comments