Oscar Reyes
Oscar Reyes

Reputation: 4342

github, sourcetree getting unauthorized error

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?

Upvotes: 17

Views: 53938

Answers (9)

Wolf
Wolf

Reputation: 6499

If all above is not work, you can try (it works for me)

  • In command, open: %LOCALAPPDATA%\Atlassian\SourceTree\passwd
  • Delete your usename and password, then try to fetch,push...in source tree, it will ask you input usename password again
  • Input new username/password. Sometime, the password is a token, (e.g. when you working with azure devopt, depend to your setting you can get the token to input to password field enter image description here

Upvotes: 0

Natasha
Natasha

Reputation: 6893

  1. In GitHub, on the top-right corner, click on the profile icon and select Settings.

enter image description here

  1. From the left-side menu, towards the bottom, select Developer Settings.

enter image description here

  1. Select the Personal access tokens option.

enter image description here

  1. now finally click on the Generate New Token button/link.

enter image description here

This will prompt you to enter your password. After entering your password, you will see a page to add new token.

enter image description here

1. Depending on the requirement, you can set an expiration for your token, or you can set "No expiration" from the dropdown.
2. For scopes, agin, upon your requirement, check-mark the necessary ones.
3. Finally hit `Generate token`.

This will generate a token. Keep a copy of the token.

1. In source tree, from the top-right, select `Settings`. 
2. In the pop-up, select remote to add your remote path for repository.
3. Copy the repository path(the .git path) from GitHub into the `URL/ path`, but now you need to add the access-token like following-

enter image description here

if the repository path is https://github.com/username/repository_name.git, you need to add the access token in-between https:// and github.com/username/repository.git with @ like-

https://[email protected]/username/repository.git

hit ok and you are good to go now.

Upvotes: 4

Ferie
Ferie

Reputation: 1436

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

Upvotes: 11

Mauro Bilotti
Mauro Bilotti

Reputation: 6232

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!

Upvotes: 4

Yuval
Yuval

Reputation: 21

I'm using Personal access tokens (GitHub -> settings -> Personal access tokens) and I needed to regenerate the token and then remove the username from SourceTree (SourceTree -> preferences -> network ->remove) then pull and you will be prompt to enter user name and password Use the token you generated

Upvotes: 2

Swarit Agarwal
Swarit Agarwal

Reputation: 2648

SOURCE TREE

Tools > Options > Authentication > Edit (Edit Password)

Upvotes: 0

ntg
ntg

Reputation: 14075

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.

Upvotes: 34

VonC
VonC

Reputation: 1323095

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

Upvotes: 5

Rick Putnam
Rick Putnam

Reputation: 546

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.

Upvotes: 2

Related Questions