我是node.js“azure-devops-node-api”的新手。我想连接我的集合, getPersonalAccessTokenHandler(token) 方法工作正常,但我想使用用户名和密码进行身份验证。getNtlmHandler(用户名,密码)确实进行了身份验证,但我无法使用这种方法获取存储库。请建议我更好的身份验证方法
const azdev = require("azure-devops-node-api");
const collectionURL = 'https://dev.azure.com/username';
let authHandler = azdev.getNtlmHandler('username', 'password');
let connection = new azdev.WebApi(collectionURL, authHandler);
connection.connect().then(connData => {
console.log(`Connection established successfully!!!. This is
${connData.authenticatedUser.providerDisplayName}. Welcome!!!`);
connection.getGitApi().then(vstsGit => {
vstsGit.getRepositories('projectName').then(repos => {
// repos is null or undefined
console.log('There are', repos.length, 'repositories in this
project');
// But When I authenticates with Token, It works fine.
});
});
});
Run Code Online (Sandbox Code Playgroud)