Vscode: Git: Support GitHub 2FA

Created on 9 Feb 2017  路  8Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.9.1
  • OS Version: Ubuntu 14.04, 16.04

Steps to Reproduce:

  1. Make changes to a GitHub repo with two-factor authentication enabled
  2. Push/Sync changes.

Error: Authentication failed on the git remote.

A dialog box appears to enter your git username/password, but there is no subsequent dialog for the two-factor authentication code, and so the process just fails.

The https protocol was used for the git clone on this repo.

feature-request git help wanted

Most helpful comment

You can create a personal access token following the instructions here:
https://help.github.com/articles/creating-an-access-token-for-command-line-use/

Then you simply use that token as the password.

All 8 comments

You can create a personal access token following the instructions here:
https://help.github.com/articles/creating-an-access-token-for-command-line-use/

Then you simply use that token as the password.

Thanks, that's a good workaround.

Still, it seems like from a UX perspective it would be nice to support at some point.

Thanks @skl131313

I"ll put my 2 cents in. It indeed would be nice to support CLI 2-factor. Make life a bit easier if we don't want to go down the token route.

Just had this issue, thanks for the token guide! 2FA in GUI would be very convenient still 馃挴

Anyone working on this? I am picking it up otherwise.

Ok, so I have been looking into this issue and have come up with some observations, issues and suggestions for how to do this.

Issues

  1. Github with the git command line provides no feedback on why the username and password was rejected. Basically github expects an access token as the password, as stated above in the work around, and if this doesn't work the only feedback obtained is that it was incorrect.
  2. There is no way of vscode knowing whether a user has 2fa enabled without authenticating with github and pulling the private user details, so nothing special can be done preemptively without authorisation.

Observations

  1. How the git extension works at the moment is that it tries to push and if prompted for a password it creates an InputBox to ask for the username and password.
  2. There is currently a MS extension vscode-pull-request-github that authenticates with github and gets the required token that would be needed to interact with the command line successfully.

Suggestions

  1. I don't think it would be ideal to have to sign in multiple times for microsoft related extensions. I think it would be preferable if the authentication and credential storage was done in a central extension which then could pass these on via an api. Obviously this would want to be restricted to MS extensions, if possible. Whether this extension could live outside the core extensions I am not 100% sure of and would like to hear the teams thoughts. Let's call it github-auth for now.
  2. Even if vs-code-pull-requests kept its own version of authentication, I would like to use their same workflow of using a web flow. I feel like this should still be its own extension to minimise the git extension's codebase having provider specific code added in.
  3. The git extension would still need to look for repositories that use a github url and request credentials to interact with the command line when executing commands. If done right I think this could be abstract enough to allow other git providers to have an auth extension which could register with the git extension.

I haven't actually started any of this work as I would like to get some feedback from the team regarding their thoughts and if this fits with the direction they current have.

As a simple starting point, I'd suggest just changing the helper text around the Github password form slightly:

"In case you have 2-Factor Authentication activated on your Github account, you will need to enter a personal access token instead of your Github password. Please see instructions on how to get your token here."

Was this page helpful?
0 / 5 - 0 ratings