| title | Sign in with a Personal Access Token (PAT), Azure DevOps CLI |
|---|---|
| titleSuffix | Azure DevOps |
| description | Use a Personal Access Token (PAT) with Azure DevOps CLI |
| ms.topic | how-to |
| ms.subservice | azure-devops-reference |
| ms.manager | mijacobs |
| ms.author | chcomley |
| author | chcomley |
| monikerRange | azure-devops |
| ms.date | 06/05/2025 |
[!INCLUDE version-eq-azure-devops]
This article explains how to sign in using an Azure DevOps personal access token (PAT). You can sign in interactively with Microsoft Entra through the az login command or by using an Azure DevOps PAT. To create a PAT, see Use personal access tokens.
[!INCLUDE use-microsoft-entra-reduce-pats]
To use a PAT with the Azure DevOps CLI, choose one of these methods:
- Run
az devops loginand enter the PAT token when prompted. - Pipe the PAT token to StdIn and use it with
az devops login.[!NOTE]
This method works only in a non-interactive shell. - Set the
AZURE_DEVOPS_EXT_PATenvironment variable and run CLI commands without usingaz devops login.
After you run the az devops login command, enter your personal access token (PAT) when prompted:
az devops login --organization https://dev.azure.com/contoso
Token:
If you already signed in interactively with az login or used a user name and password, you don't need to provide a PAT. The az devops commands now support sign-in through az login.
When you sign in successfully, this command can also set your default organization if none is configured.
Note
For Guest Users, only az devops login is supported.
You can provide your PAT to the Azure DevOps CLI by piping it to the az devops login command. This approach is useful for automation and CI/CD pipelines where interactive input isn't possible.
Replace ###### with $(System.AccessToken) or another pipeline variable:
echo "######" | az devops login --organization https://dev.azure.com/contoso/
You can also store your PAT in a file and pipe it to the login command:
cat my_pat_token.txt | az devops login --organization https://dev.azure.com/contoso/
For non-interactive or automation scenarios, set the AZURE_DEVOPS_EXT_PAT environment variable to your PAT. If you haven't used az login or az devops login, all az devops commands attempt to use this variable for authentication.
Set the environment variable at the process level before running CLI commands to enable seamless authentication.
# set environment variable for current process
$env:AZURE_DEVOPS_EXT_PAT = 'xxxxxxxxxx'export AZURE_DEVOPS_EXT_PAT=xxxxxxxxxxReplace xxxxxxxxxx with your PAT.