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

Cannot "Connect to Github" #12821

Closed
Tracked by #13192
tsmaeder opened this issue Aug 10, 2023 · 19 comments · Fixed by #13057
Closed
Tracked by #13192

Cannot "Connect to Github" #12821

tsmaeder opened this issue Aug 10, 2023 · 19 comments · Fixed by #13057
Assignees
Labels
bug bugs found in the application git issues related to git

Comments

@tsmaeder
Copy link
Contributor

tsmaeder commented Aug 10, 2023

The very useful Gitlens extensions offers to "Connect to Github" in order to directly jump to the relevant PR on github from an editor hover. This simply does not work.

To Reproduce

  1. Install gitlens
  2. Open an editor on a file in a github repo, for example theia itself.
  3. When you hover at the end of a line, you get a hover that shows you information about the commit that last changed this line.
  4. Scroll to the bottom of the hover
  5. Observe: there is a link that says "Connect to Github".
  6. Click the link
  7. Observe: nothing happens (not even messages in the browser log)
    My expectation would be that I would be taken through github authentication and then back to see links to PR's in the hover.
@tsmaeder tsmaeder added bug bugs found in the application git issues related to git labels Aug 10, 2023
@vince-fugnitto
Copy link
Member

@tsmaeder it perhaps relies on the vscode.github and vscode.github-authentication builtin plugins which are not included in blueprint?

@tsmaeder
Copy link
Contributor Author

That is entirely possible. Any reason why we're not including all the built-ins from VS Code?

@tsmaeder
Copy link
Contributor Author

Even with those extensions installed, The sign-in fails with Sign in failed: Error: Invalid scheme 'theia'.

@vince-fugnitto
Copy link
Member

That is entirely possible. Any reason why we're not including all the built-ins from VS Code?

At least for the main repo they are excluded since they rely on the git builtins. It's possible that it is something that was copied over to blueprint from the main repo.

@marcdumais-work
Copy link
Contributor

marcdumais-work commented Aug 10, 2023

On vscode, an external browser is opened towards GitHub, when the "Allow" button is pressed.

image

I think this operation fails on Theia because we have a stub for proposed "ExternalUriOpener":

https://github.com/eclipse-theia/theia/blob/master/packages/plugin/src/theia.proposed.externalUriOpener.d.ts

@AlexandraBuzila
Copy link
Contributor

@JonasHelming I can investigate this

@JonasHelming
Copy link
Contributor

Great, I assigned it to you!

@poundjd
Copy link

poundjd commented Oct 24, 2023

Status please.

@JonasHelming
Copy link
Contributor

PR is under review

@tsmaeder
Copy link
Contributor Author

With the gitlens example from the testing instructions in the linked PR, I don't even get the "Connect to Github" link anymore. Reopening.

@tsmaeder
Copy link
Contributor Author

This is weird: when I log out of Github in VS Code, I get the "Connect to Github" link again, but when I click it, nothing happens in the UI: There is an exception caught in the browser debugger:

Error: Timed out waiting for authentication provider to register

This is in TheiaIDE 1.48.300. In master I don't get the link to log in.

@tsmaeder
Copy link
Contributor Author

Turns out TheiaIDE just does not contain github-authentication. The Timeout is a false positive in plugin-authentication-service.ts#tryActivateProvider: we're racing success against timeout, but the timeout never is cancelled.

@tsmaeder
Copy link
Contributor Author

tsmaeder commented Apr 11, 2024

It seems I have a Github session in my Windows Credentials Manager. There is a problem in authentication-ext.ts#registerAuthenticationProvider: when a new registration provider is registered, we add a listener that will notify the front end of any new sessions being created. But the github AuthenticationProvider restores some sessions from the system keychain and those sessions are never communicated to the front end. Therefore, the login would not show up in the "accounts" in the left sidebar (little manikin icon at the bottom).
After fixing this problem, I get the "You have not finished authorizing" dialog mentioned in the linked PR. When I click on "yes", I get an error message saying Sign in failed: Error: No auth flow succeeded.. Debugging through the github-authentication extensions, I found two reasons:

  1. The UrlHandlerAuthenticationFlow (the regular flow) is disable, because the extension only allows it for supported clients ('vscode', etc., see https://github.com/microsoft/vscode/blob/013132a5cde7733e8fc59f633c03018ca08db9a1/extensions/github-authentication/src/common/env.ts#L22) 'theia', which comes from the vscode.env.uriScheme is obviously not included.

  2. The "device code" flow fails because it uses the command workbench.getCodeExchangeProxyEndpoints, (via GithubServer.getRedirectEndpoint()) which is a vscode-internal command we don't implement. Note that it's not a command documented in https://code.visualstudio.com/api/references/commands

In short: the gitub-authentication extension relies on VS Code internals and therefore does not work with Theia. Possible workarounds would be to return vscode from vscode.env.uriScheme. Not sure whether that has other unforeseen consequences, though.

@tsmaeder
Copy link
Contributor Author

Hmh...I'm not sure using the UrlHandlerFlow is a good idea anyway: it requires having the github app client secret available to the VS Code app, which is not recommended practice.

@tsmaeder
Copy link
Contributor Author

tsmaeder commented Apr 12, 2024

So even with the scheme changed to vscode, this does not work, since we obviously don't have access to the vscode github app client secret. Not sure how to implement the workbench.getCodeExchangeProxyEndpoints command. I looked for the implementation in VS Code, and it's totally obscure how these get configured.
Also, I'm not convinced we are even registered as a url handler for theia://.... anywayy, see #13306 (comment)

@tsmaeder
Copy link
Contributor Author

Maybe it's simplest to write our own "github" authentication provider?

tsmaeder added a commit to tsmaeder/theia that referenced this issue Apr 17, 2024
Also includes code to consider sessions which are not created, but
restored from storage at registration time

Fixes eclipse-theia#13599
Partial fix for eclipse-theia#12821

Contributed on behalof of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
tsmaeder added a commit that referenced this issue Apr 30, 2024
Also includes code to consider sessions which are not created, but
restored from storage at registration time

Fixes #13599
Partial fix for #12821

Contributed on behalof of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
jfaltermeier pushed a commit that referenced this issue May 2, 2024
Also includes code to consider sessions which are not created, but
restored from storage at registration time

Fixes #13599
Partial fix for #12821

Contributed on behalof of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
@tsmaeder
Copy link
Contributor Author

Seems the Electron case (device token flow) is broken again. @JonasHelming.

@tsmaeder
Copy link
Contributor Author

tsmaeder commented Aug 2, 2024

Duh! I had cleaned out my .theia-ide settings folder, including the installed "github-authentication" vscode extension. The workflow works fine 🤷

@tsmaeder
Copy link
Contributor Author

tsmaeder commented Aug 6, 2024

Closing, as this works on the desktop now.

@tsmaeder tsmaeder closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application git issues related to git
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants