github, sourcetree getting unauthorized error

43,489

Solution 1

its because i made a two-factor security

Following the Heartbleed bug, GitHub has reset all browser sessions that were active prior to the vulnerability being addressed on our servers.

Check if your PAT (Personnal Access token) is still valid in the Applications section of your GitHub Account.

Note that ssh keys have no effect on an https url like https://github.com/Nosthertus/nodejs_Chat.git

Would you need to use your ssh key, you should at least change the origin url:

git remote set-url origin [email protected]:Nosthertus/nodejs_Chat.git

Solution 2

If your password recently changed, select the repository, go to Tools --> options, go to Authentication tab and delete the stored password. This will make the system request a new password when you next try to connect.

On OSX: go to SourceTree --> Preferences --> Network and delete the default username there.

Solution 3

To work with GitHub's two-factor authentication in SourceTree you can simply use your access token instead of your password. The steps to do this are as follows:

  1. Go to your Personal Access Tokens settings in GitHub.
  2. Click on the Generate new token button.
  3. Name the token something descriptive.
  4. Select which scopes you wish to grant this token.
  5. Click the Generate token button.
  6. Copy the token and use it as a password in your hosted repositories.

Source

Solution 4

Make sure that your credentials are OK (please check before in the GitHub website), then, in my case the answer was the following.

1) Delete the "psswd" file without opening Sourcetree:

C:\Users\USER\AppData\Local\Atlassian\SourceTree\passwd

2) After doing that, try to re-enter the application and specify your credentials again.

3) If the previous steps doesn't work, in my case, it was using an incorrect username, so you can edit the "userhosts" file located in the same folder and change to the proper username that you're using:

C:\Users\USER\AppData\Local\Atlassian\SourceTree\userhosts

By doing this, I was able to push again. Hope it helps!

Solution 5

I am using 2FA and I was able to resolve authentication issues by creating an API key as described in the linked document:

https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html

Note: after generating the key, copy it and replace your password with the API key in SourceTree (Tools/Options/Authentication tab --> select item in Saved Passwords and click edit...)

I hope this helps.

Share:
43,489
Oscar Reyes
Author by

Oscar Reyes

Started as back-end web developer on PHP using Yii on my first project, i am always eager to learn new technologies and so i have started developing in HTML and JavaScript, thanks to my knowledge with JavaScript and my experience on back-end, i am now developing Node.js applications. I am always open to new ideas and better ways to improve code and my self as a developer, i look forward to grow in this field and achieve all my goals Desired technologies to work: Android, Desktop applications, Arduino

Updated on July 09, 2022

Comments

  • Oscar Reyes
    Oscar Reyes almost 2 years

    im new to github and im using sourcetree for my git gui, ive been using it for a few days, but now lately im getting an error that says

    remote: Invalid username or password.
    fatal: Authentication failed for 'https://github.com/Nosthertus/nodejs_Chat.git/'
    

    also when i tried to make another registration to github returns with error

    authorization failed
    

    maybe its because i made a two-factor security, i thought on making a shh-key with github, but does not fix the problem, there has to be a way to make my gui connect to my github account without the login access, how do i fix this?

  • real_yggdrasil
    real_yggdrasil about 7 years
    As far as im concerned, this should be the accepted answer to this question. Only when i read this, i realized how to reset the git password for a selected repository.
  • Devin Walker
    Devin Walker almost 7 years
    This worked well for me compared to the other answers. Using the personal token as the password alongside my github email.