SourceTree & SourceTree-Beta macOS Fail Authentication with Local BitBucket Server
Asked by Andrew Seago:

UPDATE: Tower 2.6.4 works without issue.

System: macOS 10.13.4b1

SourceTree Versions Affected: 2.7.1 beta latest build 2018-02-06 \& 2.7

BitBucket Server: 5.7.1

ISSUE: When setting up the Bitbucket AD linked account in SourceTree it is unable to authenticate on both ssh and https.

http error window:

"The remote service said: 'The operation couldn't be completed. (SDNetDomain error 7.)'"

http error log:

2018-02-06 19:59:30 +0000 () \[AUTH\] Removing the token available in the client before re-authentication  
2018-02-06 20:00:26 +0000 () \[AUTH\] signing out of Bitbucket Server account

ssh error window:

"The remote service said: 'The operation couldn't be completed. (SDNetDomain error 7.)'"

ssh error log:

2018-02-06 19:59:30 +0000 () \[AUTH\] Removing the token available in the client before re-authentication  
2018-02-06 20:00:26 +0000 () \[AUTH\] signing out of Bitbucket Server account

Attempted Fixes:

Delete all SourceTree files from \~/Library/

Delete Account and Recreate

Try Beta SourceTree Build


Answers:
author: Manju
body: From the logs you've pasted here, it looks like you are trying to use Bitbucket Server account with OAuth. Can you confirm that?

Currently, we do not support OAuth for Bitbucket Server accounts. Please try to add the account in Preferences with basic auth and that should work. If you encounter an issue with that, report back here with details.

comments: author: Andrew Seago
body: This is while using basic AUTH selected. And I have purged all settings and created it again. I agree it seems to be attempting OAuth. But its not in a setting I was able to choose.


author: Manju
body: Can you check if the keychain has an item with the title \<yourbbserver\> Access key for \<yourusername\> and there is a file \<yourusername\>@STAuth-\<yourbbserver\> at \~/Library/Application Support/SourceTree/ ?

If the account was successfully added, these two items must be found.

If not, remove the account in Preference and add it again. (do not edit the existing account). If the keychain item isn't found this time, restart the mac once and try again. This happens when there is a permission issue with keychain allowing access to Sourcetree.


author: Andrew Seago
body: SourceTree creates application password entries in my local keychain: \<yourbbserver\> Access Key for \<yourusername\>

SourceTree does prompt for keychain access and is allowed access. And since it is writing to the keychain it has access. The same log entries however appear. This time prior to switching from Bitbucket to Bitbucket server I selected Basic auth as that option is grayed out when you select Bitbucket server. This did not make any difference.


author: Manju
body: Alright! This is a little weird.

An access prompt for that particular keychain item must come up ideally. Just because Sourcetree wrote it doesn't mean it has access to it. Just to test, under access control of the keychain item, can you set "Allow all applications to access this item" and see if it helps?


author: Andrew Seago
body: Key Access does prompt for allowing SourceTree access to the keychain and the entry does allow sourcetree access. Seen in picture below![Screen Shot 2018-02-07 at 2.19.05 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/14318iBA8209115524CB5B/image-size/large?v=v2&px=999 "Screen Shot 2018-02-07 at 2.19.05 PM.png")

Also, Remote Repositories do populate however when I go to clone them is when I receive the error below.![Screen Shot 2018-02-07 at 2.21.34 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/14319i42C602B526452E2A/image-size/large?v=v2&px=999 "Screen Shot 2018-02-07 at 2.21.34 PM.png")


author: Manju
body: Other than what you've already provided above, do you have any other logs when this happens?

If not, you can enable debug mode logging by running below command.

`defaults write com.TorusKnot.SourceTreeNotMAS ``"LogLevel"` 5

Remember to restart the app after enabling debug logging.

Also, can you specify if you are using https or ssh?

Thanks!


author: Andrew Seago
body: HTTPS and I've ran the command and I see it in the plist but I'm not seeing any additional logging. Should this also be loging in the \~/Library/Logs/SourceTree directory?


Tags: bitbucket