This directory contains comprehensive documentation for getting started with the Azure DevOps Node API, including authentication methods and initial setup.
If you're new to the Azure DevOps Node API, start with the Getting Started Guide, which provides a comprehensive introduction to setting up and using the API. Then check the Authentication Guide for details on authentication methods.
The Azure DevOps Node API supports several authentication methods:
Each guide includes practical code examples that you can adapt for your applications. Here's a simple example of PAT authentication:
import * as azdev from "azure-devops-node-api";
// Get authentication credentials from environment variables
const orgUrl = process.env.AZURE_DEVOPS_ORG_URL;
const token = process.env.AZURE_DEVOPS_PAT;
// Create a PAT authentication handler
const authHandler = azdev.getPersonalAccessTokenHandler(token);
// Create the WebApi connection
const connection = new azdev.WebApi(orgUrl, authHandler);
// Use the connection
async function useConnection() {
try {
// Test the connection
const connData = await connection.connect();
console.log("Connected successfully!");
} catch (error) {
console.error("Error connecting:", error);
}
}
useConnection();
Authentication credentials provide access to your Azure DevOps resources, so it's essential to handle them securely:
For detailed security guidance, see the Security Best Practices guide.
If you encounter issues with authentication, consult the Troubleshooting Connection Issues guide, which covers common authentication problems and their solutions.