Skip to content

Support VSCode builtin GitHub authentication #1074

Description

@felipecrs

VSCode now provides GitHub authentication for git even in its Terminal.

If gh had support for that too, we could have a seamless GitHub Authentication when using gh inside VSCode, which can mainly benefit vscode-dev-containers , Visual Studio Codespaces, and therefore, the upcoming GitHub Codespaces.

Activity

  1. mislav commented on Jun 2, 2020

    @mislav
    Contributor

    Hi thank you for letting us know! You bring up a good point that this would make it easier to get going with gh inside Codespaces. ✨

    Unfortunately, I don't think we can piggy-back on VSCode authentication for our needs. First of all, that authentication is probably done via an OAuth app of their own, and we need to connect to our "GitHub CLI" OAuth app for the purposes of ocassionally getting access to some preview APIs. Second of all, we don't know which OAuth scopes does the VSCode authentication request, but since it's only git, it's probably only requests the repo scopes. CLI needs a few more scopes than that, namely read:org at least.

    This is mostly just me guessing, though, and if anybody would be willing to dive into VSCode source and look up how they set up this authentication and link it here, I would be grateful!

    Ref. #297

  2. Lewiscowles1986 commented on Jun 2, 2020

    @Lewiscowles1986

    I'll be honest that workflow in VSCode broke my private key workflow, which in itself was a workaround to their git tooling being only useful for choosing which files to git add. I'm furious with them

  3. felipecrs commented on Jun 2, 2020

    @felipecrs
    Author

    @mislav The PR relevant on VS Code: microsoft/vscode#96069

    It seems that GitHub Authentication is provided by VS Code to git CLI through GIT_ASKPASS.

  4. felipecrs commented on Jun 2, 2020

    @felipecrs
    Author

    If the scope of authentication provided to git isn't enough, then certainly the GitHub extension can contribute with it, since it has the required scopes.

  5. felipecrs commented on Jun 24, 2020

    @felipecrs
    Author

    I just had another idea: gh could support an environment variable called GH_HOSTS which is taken as a preference over ~/.config/hosts.yaml. VS Code could them create this file, fill the information (username and token) and contribute to the environment of the integrated terminal with this variable. This way, we at least don't have to fully expose GITHUB_TOKEN in an integrated terminal to make this happen.

  6. mislav commented on Jun 25, 2020

    @mislav
    Contributor

    gh could support an environment variable called GH_HOSTS which is taken as a preference over ~/.config/hosts.yaml

    That's not a bad idea in general, but there is still the problem I outlined above: we would generally prefer if gh used a token that's tied to its own OAuth app, rather than one generated by another OAuth app. That's why I said that piggybacking on another tool's authentication mechanism could lead to limited functionality.

  7. ljtill commented on Jul 3, 2020

    @ljtill

    Not the solution but in case it's useful for anyone; I've found adding a Personal Access Token in the Environment Variables (GITHUB_TOKEN) settings within VS Codespaces has solved this challenge in the short term.

  8. added
    coreThis issue is not accepting PRs from outside contributors
    on Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIneeds-investigationCLI team needs to investigate

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions