Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Authentication failed on Gitlab account adding

danicaballero February 20, 2019

Hi,

 

   It seems to be impossible to add an existing GitLab account to SourceTree. When requested for authentication, though using correct username and fresh password, it continuously fails.

 

   Any suggestions that doesn't involve using a different repo provider?

9 answers

1 accepted

3 votes
Answer accepted
minnsey
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2019

Hi

You need to use a Personal Access Token https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html

We are improving the text on those dialogs to reflect this

danicaballero February 21, 2019

Thanks for the suggestion. I should have elaborated the steps that lead to the issue.

In first instance, an attempt to text copy the personal token from Gitlab to Sourcetree proved impossible to accomplished. The text box for the personal token was present but completely inactive, making impossible to write and/or copy text.

The next step was to click on the Refresh Personal Token. This popped up a login window, which lead to the authentication issue.

Any options to introduce the Personal Token?

Thanks

minnsey
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 21, 2019

Sorry, to clarify.

yes you need to click on the Refresh Personal Access token and then in that popup dialog enter your username and use the PAT as the password there.

Is this what you were doing and you still got the error?

Like # people like this
danicaballero February 22, 2019

I proceeded as you suggested and that worked smoothly. Thank you very much!

 

I would suggest changing the UI and messaging a little. The whole thing is a bit misleading.

Like Grace Chang likes this
minnsey
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 26, 2019

Yes, some small improvements are already in progress

Mauro Miotello May 7, 2019

Hi, i've same problem using SourceTree 3.1.2 (216) but i no have a Refresh Personal Access token button !

How can i do ?

sourcetree-account-gitlab.png

Like # people like this
Rob Majors January 2, 2020

Since this question has been marked as Solved but the problem still exists for later Sourcetree versions, or for Sourcetree on Mac, or both together, I have opened a new question to address the remaining problem here.

Rob Majors January 3, 2020

Solution found: enter your personal access token as the password. Do not enter your GitLab password.

It's not clear to me which scopes are required for the personal access token in this case. I used "api" and "read_user" and they worked for me.

Like # people like this
Grace Chang August 19, 2020

Entering the token helps with the Account add for Sourcetree; however, when you push/pull changes, you get the following prompt and the token doesn't clear this password requirement:

 

Screen Shot 2020-08-19 at 9.30.17 AM.png

Screen Shot 2020-08-19 at 9.31.19 AM.png

Grace Chang August 21, 2020
Angus Freeman May 21, 2023

This works, but only for ONE gitlab account. If you have to sign into more than one gitlab account, you will constantly be kicked out of the previous one as soon as you refresh credentials for another one. How can you down vote this "accepted" answer?

7 votes
Quy Ho September 18, 2019

1. Go to this link https://gitlab.com/profile/personal_access_tokens and create a personal access token

2. From source tree, Tools/Option.  Click Authentication tab, add account, choose gitlab and enter username as name of personal access token, password is Personal Access Token. 

=> Done

joseposes22 September 18, 2019

WTF!! this workarround works!

We put password as access token and our username and works fine.

Mike Gibbons October 2, 2019

I'm using 3.1.2 on a Mac and running into this same issue, except I don't see Tools / Options anywhere within Sourcetree and no option to Refresh PAT. Please help!

Cooper Kai July 29, 2020

Hi joseposes22, I'm using 3.1.2 on my windows 10. I've tried your method, but it didn't work. 

babarykin_denis August 21, 2020

For me it didn't work too.

2 votes
MichaelB July 12, 2019

Unable to find Refresh Personal Access token button on SourceTree 3.1.2 (225).
How Can we do?
Team , Please look into this asap.
Thanks


Screenshot 2019-07-12 at 8.22.26 PM.png

1 vote
Oana Mada January 28, 2022
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
After this, I was able to Clone Repository ("Clone from URL").
1 vote
Grace Chang August 19, 2020

I'm now able to add the account with the token hack; however, on git push/pull I get a password request where neither my Gitlab password or token works.

Grace Chang August 21, 2020

It turns out the prompt is asking for the `ssh` password, see Gitlab support thread here:

https://forum.gitlab.com/t/unable-to-authenticate-gitlab-in-sourcetree/41623/4

1 vote
Josef Micka January 14, 2020

not working at all. i even removed all auhentication fields, yet when i try to push my code to gitlab repo i get basic auth failed, you need access token.

 

i did setup access token, my access token has FULL access.

 

in old 1.9 source tree same token works flawless, but in new fugly 3.x nothing works. removing all account restarting git, doesn't work. adding manually account to setting (which creates 2 entries, one for basic auth, and one account) doesn't work. yes PAT refresh token says SUCCESS but PUSH to repository always fails.

 

guys can you finally fix this? 

 

it's huge pain, and whenever i forget to decline upgrade to 3.x shit. i need to revert back to 1.9 to get working git client.

Josef Micka January 14, 2020

ok small update (i found this, when i was solving another problem - after update terminal didn't work - switching to "system" git instead of embeded git solved not only terminal problem, but also "authentication" issue)

so authentication doesn't work with embeded git, but does work with system git.

Like Aaron Gerston likes this
Jacobo Campos January 29, 2020

Hi, 

 

I have system git version selected...

image.png

I use GitLabEE, and when I refresh Personal Access Token and I put my GitLab username y the PAT generated token from GitLab, it does not work.

image.png

image.png

image.png

So, it is impossible to connect. Please, could anyone recommend me another tool, NOT Sourcetree? Thanks!!

Like Thuy_Doan likes this
Yosmangel Adames February 18, 2020

I created a new token, using my username like name of token and when I tried to login in sourcetree, in my password I type thisasdadadsad.PNG

And my login was successful

Deleted user June 5, 2020

After more than a year, it's still an issue that forced me to google and waste 30min of my time reading discussion threads! 

1 vote
jonathan bar November 15, 2019

If anyone else can't resolve this, of course follow @Quy Ho's instructions, but also make sure you're choosing the correct GitLab Hosting Service. Mine was GitLab CE and I spent some unnecessary time trying to log in with GitLab.

elana.van.der.kolff November 10, 2020

GitLab EE ended up working for me. Thanks!

0 votes
Triet Hoang Minh Nguyen June 15, 2021

Hi, I would like to recommend to all guys this link and it works for me
https://www.awordfromnet.com/access-gitlab-via-sourcetree-updated/

As I know, this resolved my issue when I put my PAT as password and username for login. But it seems to not working because it is missing api scope.

It’s probably late, but hopefully it helps you.

0 votes
John McKiernan
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 29, 2020

Hi all, 

Just wanted to update this thread to let you know there is now a native automation trigger for GitLab with Jira Cloud. We are running a webinar soon to walk through how it works and show some use cases in how to automate from Gitlab to Jira. Feel free to register here: https://www.atlassian.com/webinars/software/automate-across-gitlab-and-jira

Cheers!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events