Use the Cross-platform CLI for Azure DevOps using personal access tokens
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
Use personal access tokens (PATs) with the cross-platform CLI for Azure DevOps.
Important
We don't recommend using basic authentication. For Azure DevOps Services, see Sign in with a PAT.
Prerequisites
Download the latest version of Node.js source code, from the Node.js source code downloads page
Install the Cross-platform CLI for Azure DevOps
- Install tfx-cli using
npm
, a component of Node.js by running:
npm i -g tfx-cli
For more information about tfx-cli, see the Node CLI for Azure DevOps on GitHub.
- Install tfx-cli using
Personal access token
Create a personal access token and paste it into the sign-in command.
~$ tfx login
Copyright Microsoft Corporation
> Service URL: {url}
> Personal access token: xxxxxxxxxxxx
Logged in successfully
See the following examples of valid URLs:
https://marketplace.visualstudio.com
https://youraccount.visualstudio.com/DefaultCollection
Configure for Basic authentication
Warning
We don't recommend basic authentication. Turning on IIS basic authentication causes various issues, and you should use personal access tokens (PATs) instead. For example, if you turn on IIS basic authentication, GIT command line stops working.
Follow these steps to enable basic auth for your Azure DevOps instance:
Warning
Basic authentication sends usernames and passwords in plaintext. Consider configuring Azure DevOps Server to use SSL to enable secure communication when using basic auth.
Install the
Basic Authentication
feature for IIS in Server Manager.Open IIS Manager and expand to the
Azure DevOps Server
website, double-click theAuthentication
tile in the Features view.Choose
Basic Authentication
in the list of authentication methods. ChooseEnable
in the right hand column. You should now seeBasic Authentication
enabled.
Note
Leave the domain and realm settings for Basic Authentication empty.
tfx sign in with Basic authentication
Now you can start to use tfx
against your server. Sign in before you issue commands.
Enter the following command:
tfx login --auth-type basic
Add your service url.
Add your username. Use
domain\user
(for example, fabrikam\peter). If you're working on a workgroup machine, usemachinename\user
.Add your password. Enter the password for the username that you previously entered.
You can now use any other tfx command.
> tfx login --auth-type basic
Copyright Microsoft Corporation
Enter service url > http://localhost:8080/tfs/defaultcollection
Enter username > fabfiber\peter
Enter password > *******
logged in successfully