I experience an issue using SourceTree and GitHub PATs (Personal Access Tokens).
SourceTree version: 3.4.26
OS: Windows 11
Preconditions: I have removed all accounts using Tools > Options > Authentication
1. I want to add a new repo tab and click '+'
2. Then select 'Remote' and 'Remote repositories' screen appear
3. Then I click 'Add an account...' and dialog 'Edit Hosting Account' is shown
4. I select GitHub, HTTPS, Personal Access Token
5. Then I click 'Refresh Personal Access Token'
6. In the dialog showing I put my PAT in the 'Password' field and leaving 'Username' blank
7. Clicks 'OK'
8. Now I get an error message in the 'Edit Hosting Account' dialog:
Login failed Authentication failed for GitHub with username myusername - please check your account settings.
9. Now I switch to 'Clone' - tries to clone - and it works! Hence the account has been created despite the error message.
9.b. I also tried to run git pull on CLI - and it worked.
9.c. When I tried to Pull an existing local repo in ST it worked.
So something seems to be wrong when creating the account in Sourcetree, and this also somehow affects/stopping the account to be listed in 'Remote repositories' screen.
This seems to be quite similar to what is reported previously here:
https://community.atlassian.com/forums/Sourcetree-questions/Unable-to-connect-to-Github-Enterprise-with-PAT/qaa-p/3117462#M46540
How is the process of investigating and fixing such issues for Sourcetree?
@Brede Fladen the process is mainly to try out everything until one thing starts working 😅
As written in linked thread, you could try out some of the methods mentioned there, or something like the following:
Clear Existing Credentials: Even though you've removed accounts in Sourcetree, ensure you also navigate to the Windows Credential Manager and remove any stored entries related to
github.com.Use a Placeholder Username: When prompted in the "Edit Hosting Account" dialog, instead of leaving the username blank, try entering your actual GitHub username alongside the PAT in the password field.
Verify Token Scopes: Ensure your GitHub PAT has the minimum required scopes. For Sourcetree to list remote repositories, it typically requires
repo,read:org, anduserscopes.Switch to OAuth: If PAT continues to fail the validation check in the UI, try changing the Authentication method to OAuth. This will open a browser window to authenticate, which is often more reliable for populating the Remote repositories list
I have only used/tested PAT once, and I'm not near my main PC for the next couple of days so I won't be able to troubleshoot this 👀
Also, have you tried upgrading to the latest official version (3.4.30)? I mean, this shouldn't correlate, but it might be worth a try.
Cheers,
Tobi
Thanks, @Tomislav Tobijas
I've tried quite a lot things.
1. Clear Existing Credentials: Tried that and as I wrote the added account is actually created even if there is an error message, and it's working in other scopes than Remote repositories. Strange.
2. Placeholder Username: Yes, tried this. Didn't make any difference.
3. Token scopes: PATs are using a little bit different wording, but with the below ones I'm able to do everything needed (so far) except for viewing the account in the Remote repositories screen:
Organization:
Repository:
Switch to OAuth: The purpose is to get away from OAuth because it's not possible to limit permissions for OAuth. So yes it's working but I need PAT to work properly.
Version 3.4.30 - EDIT: Tried v3.4.30 now - no change, same problems. No, not tried it yet. But couldn't find anything in the release notes that pointed to any fixes in this direction.
Thanks for your input!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.