Cannot add GitLab account due to authentication failure (Sourcetree 4.0 on Mac)
Asked by Rob Majors:

**Steps to reproduce**

1. In Sourcetree go to Remote \> Accounts... \> Add...
2. Select one of the GitLab hosts (I'm using GitLab Enterprise) and provide a URL if required
3. Enter username and password
4. Select the HTTPS protocol (per the comments in the question linked below this also happens if using SSH)
5. Click "Save"

**Result**   
The following dialog always appears:
> **Login error**
>
> We couldn't connect to GitLab Enterprise with your (\<your_username\>) credentials. Check your username and try the password again.

**Environment**

I am encountering this on Sourcetree 4.0 (229) on macOS 10.14.6

**Additional information**

As in the comments to [this question](https://community.atlassian.com/t5/Sourcetree-questions/Authentication-failed-on-Gitlab-account-adding/qaq-p/1013950): there was a set of steps which would resolve this issue in Sourcetree versions prior to circa 3.1.2 (216 or 225) but from that point on the UI changed and it was not possible to follow these steps, or possibly these steps never worked on the Mac Sourcetree application.

In particular, there is now nowhere in the Sourcetree UI where it is possible to load or specify a Private Token once one has been generated in GitLab.

That question is marked as Resolved and thus no further assistance has been provided there, so I am opening a new question to get help with the problem in its current form.


Answers:
author: Rob Majors
body: SOLUTION: In step 3, enter your personal access token as the password. Do not enter your GitLab password.

comments: author: Michael Bechard
body: This doesn't work for me, on Sourcetree 4.0.1. I'm on Mac 10.14.5.


author: Jurjen van Dijk
body: Works for me on SourceTree 4.0.1. OS X 10.14.5


author: smityfke
body: This doesn't work for me too, on Sourcetree 4.0.1 Mac OS X 10.15.3


author: kostiag
body: same problem does not work source tree 4.0

I take it back using generated access token worked


author: Florin Steliean
body: It is not working for me on Sourcetree 4.0.2 and macos 10.15.7. Still getting the same error


author: Andr? Sebastian-Bath
body: Neither working for me. Used my email + access token on Mac OS 10.15.7 and 4.0.2 :(


author: Grace Chang
body: Adding the token seems to work as a password hack; however, when I git push/pull, I'm prompted with another auth that fails with either my Gitlab password or the token.

![Screen Shot 2020-08-19 at 9.36.53 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/107235iB14B555E6E79C7ED/image-size/large?v=v2&px=999 "Screen Shot 2020-08-19 at 9.36.53 AM.png")![Screen Shot 2020-08-19 at 9.31.19 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/107234i8B410D0604070B7A/image-size/large?v=v2&px=999 "Screen Shot 2020-08-19 at 9.31.19 AM.png")


author: Oana Mada
body: **PROBLEM SOLVED**  
The **solution** was (on Mac):  
- revoke the old Access Token from GitLab (which had only the next Scopes: read_repository, write_repository)  
- generate new Access Token having the next Scopes: **api, read_user** , read_repository, write_repository*(it was strange that for other colleague it worked only with read_repository, write_repository)*  
- on SourceTree: go to SourceTree -\> Preferences -\>Accounts -\> Add -\> fill-in the details as in the following image (and for Password use the Access Token):  
![img.png](https://community.atlassian.com/t5/image/serverpage/image-id/180460i364BC58E3F3F7684/image-size/large?v=v2&px=999 "img.png")  
After this, I was able to Clone Repository ("Clone from URL").  
Also, this link inspired me: <https://www.awordfromnet.com/access-gitlab-via-sourcetree-updated/>