Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support VSCode builtin GitHub authentication #1074

Closed
felipecrs opened this issue Jun 2, 2020 · 7 comments · Fixed by #2207
Closed

Support VSCode builtin GitHub authentication #1074

felipecrs opened this issue Jun 2, 2020 · 7 comments · Fixed by #2207
Labels
core This issue is not accepting PRs from outside contributors enhancement a request to improve CLI needs-investigation CLI team needs to investigate

Comments

@felipecrs
Copy link

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.

@felipecrs felipecrs added the enhancement a request to improve CLI label Jun 2, 2020
felipecrs added a commit to price-search/api that referenced this issue Jun 2, 2020
- Install GitHub CLI, despite authentication is not seamless. See
  cli/cli#1074
- Remove unused code and some comments
- Set Prettier as default formatter
felipecrs added a commit to price-search/api that referenced this issue Jun 2, 2020
- Install GitHub CLI, despite authentication is not seamless. See
  cli/cli#1074
- Remove unused code and some comments
- Set Prettier as default formatter
@mislav
Copy link
Contributor

mislav commented Jun 2, 2020

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

@Lewiscowles1986
Copy link

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

@felipecrs
Copy link
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.

@felipecrs
Copy link
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.

@felipecrs
Copy link
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.

@mislav
Copy link
Contributor

mislav commented Jun 25, 2020

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.

@ljtill
Copy link

ljtill commented Jul 3, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core This issue is not accepting PRs from outside contributors enhancement a request to improve CLI needs-investigation CLI team needs to investigate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@mislav @vilmibm @ljtill @Lewiscowles1986 @felipecrs and others