Connect to Azure devops repo using sourcetree on MacOS

Viewed 21518

I've created a new project on azure devops and now I'm trying to add an account to sourcetree:

I've setup the opions in the following way:

Host: Azure devops

Link next to Host: https://myuser@dev.azure.com/myuser
Also tried with https://dev.azure.com/myuser

Auth Type: It's locked to private token, can't change it.

Username: Tried with my email, also enabled alternative credentials and tried with that username.

Password: Tried with the real password as well as the personal access token

Protocol: HTTPS

I keep getting the error: We couldn't connect to Azure DevOps with your credentials. What could be the cause of this?

7 Answers

Although SourceTree for macOS has updated the name of Azure DevOps (from "Visual Studio Team Services"), it appears that it does not support the new Azure DevOps URLs.

You can use the old-format (VSTS-style) URLs. Instead of https://dev.azure.com/username, you can use https://username.visualstudio.com.

SourceTree

Ironically, it seems that SourceTree for Windows still calls the product "Visual Studio Team Services" but supports the new-style Azure DevOps URLs.)

I was successful with Preferences/Accounts/Azure DevOps

https://dev.azure.com/{organisation}/
{username}
{token}
HTTPS

and using this remote url

https://{username}@dev.azure.com/{organisation}/{projectname}/_git/{repository}

You need to set up a Personal Access Token.

The below is from the documentation

Personal access tokens (PATs) are alternate passwords that you can use to authenticate in to Azure DevOps and Team Foundation Server (TFS). In this article, we walk you through how to create or revoke PATS.

Azure DevOps Services and TFS use enterprise-grade authentication to help protect and secure your data. Clients like Visual Studio and Eclipse (with the Team Explorer Everywhere plug-in) also support Microsoft account and Azure AD authentication.

For non-Microsoft tools that integrate into Azure DevOps but don't support Microsoft account or Azure AD authentication, you must use PATs. Examples include Git, NuGet, or Xcode. To set up PATs for non-Microsoft tools, use Git credential managers or create them manually.

Basically, you need to:

  1. generate the PAT
  2. In Sourcetree, add a new account with the PAT as username AND as password
  3. If Sourcetree seems to be making you struggle (caching or not picking the right account if you have multiple) just add :yourorgname.visualstudio.com/projectname

PS: I wrote a post on this (this one), check it out if you want the full details.

After surfing entire internet I found the answer.

Refer this link and at Point 4., remember to add expiration date. By default it selects existing date, you need to select expiration date. It was this place where I did not select expiration date and it keeps throwing login error message.

I selected 1year from today as expiration date, Full Access under Scopes.

Your clone > HTTPS Link wont work. Like this URL

Follow @Edward Thomson format to input URL

Username: Your generated Token

Password: Your generated Token (same as Username)

OR

Username: Your email to Azure DevOps

Password: Your generated Token

@taigi100 You can delete token by selecting revoke on Azure DevOps

@taigi100 @Murray Foxcroft - Hope this helps.

After much experimentation this was my experience from today:

  • You need to create a DevOps Personal Access Token for authentication, SourceTree can't authenticate with your normal Azure username/password combination.
  • Remove any DevOps-related entries displayed in SourceTree > Preferences > Accounts.
  • In the properties of the local SourceTree repo > Settings > Remotes > origin enter:
    • URL / Path: https://{yourAzureUsernameOrEmailAddress}@dev.azure.com/{orgName}/{projectName}/_git/{repoName}
      • IMPORTANT: If yourAzureUsernameOrEmailAddress is an email address be sure to replace its @ symbol with the %40 URI encoding otherwise it will send the domain-portion as your username. e.g.: https://foo%40example.com@dev.azure.com/...
    • Host Type: Unknown

Now when you Pull/Push/Fetch you should see a "Password Required" dialog "For user yourAzureUsernameOrEmailAddress on host dev.azure.com":

  • Password: {yourPersonalAccessToken}

Be sure to enter your PAT, not your password.

It should be successful and if you elected to "Store Password in Keychain" then you should be able to go to Keychain Access > login > Passwords and see and entry for dev.azure.com Access Key for yourAzureUsernameOrEmailAddress listed.

My experience on MacOS and devops was:

  1. Delete recent password/key on keychain access.
  2. Try to pull again, sourcetree will ask for password.
  3. Input your PAT you got from your account on devops, and this should work.
Related