Azure DevOps Node API Authentication

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:

  1. Personal Access Tokens (PATs) - Recommended for most scenarios
  2. Basic Authentication - Simple username/password authentication
  3. OAuth 2.0 - Ideal for web applications and multi-tenant scenarios
  4. NTLM Authentication - For on-premises Azure DevOps Server deployments

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:

  • Never hardcode credentials in your source code
  • Use environment variables or secret management services
  • Set appropriate token expirations
  • Implement proper token rotation policies

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.