Provide automatic git authentication to GitHub #96069
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #96241
The Git extension currently already hijacks into the
GIT_ASKPASS
mechanism to provide UI to prompt the user for credentials when they try to run git commands over an HTTPS-based remote and do not have any credential manager installed:This PR adds a new
registerCredentialsProvider
method to the Git extension API which allows other extensions to contribute to that mechanism and provide credentials themselves, before the last resort of prompting the user is used. Using the newvscode.authentication
API, an extension can easily provide GitHub access tokens as credentials. We would have automatic authentication for allGit: Pull
,Git: Push
, etc. commands in our UI for GitHub repositories!We could implement this in the GHPR extension, but another option is to simply implement this in the
github-authentication
core extension. Why not have this built into the core?This PR implements exactly that.
The authentication authorization dialog currently looks like this:
It feels strange that
GitHub Authentication
appears in there.GitHub
?github
, for that matter?Also, while this tackles git commands in the UI, it doesn't address terminal commands yet. Once #96061 lands, we'll be able to simply add a
GIT_ASKPASS
env var to terminals and evengit pull
,git push
, etc. commands in the integrated terminal would have GitHub automatic authentication working.cc @egamma @kieferrm @RMacfarlane @Tyriar @chrisdias