theia
theia copied to clipboard
Cannot "Connect to Github"
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
- Install gitlens
- Open an editor on a file in a github repo, for example theia itself.
- 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.
- Scroll to the bottom of the hover
- Observe: there is a link that says "Connect to Github".
- Click the link
- 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 it perhaps relies on the vscode.github
and vscode.github-authentication
builtin plugins which are not included in blueprint?
That is entirely possible. Any reason why we're not including all the built-ins from VS Code?
Even with those extensions installed, The sign-in fails with Sign in failed: Error: Invalid scheme 'theia'
.
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.
On vscode, an external browser is opened towards GitHub, when the "Allow" button is pressed.
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
@JonasHelming I can investigate this
Great, I assigned it to you!
Status please.
PR is under review
With the gitlens example from the testing instructions in the linked PR, I don't even get the "Connect to Github" link anymore. Reopening.
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.
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.
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:
-
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. -
The "device code" flow fails because it uses the command
workbench.getCodeExchangeProxyEndpoints
, (viaGithubServer.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.
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.
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 https://github.com/eclipse-theia/theia/pull/13306#issuecomment-1910452763
Maybe it's simplest to write our own "github" authentication provider?
Seems the Electron case (device token flow) is broken again. @JonasHelming.
Duh! I had cleaned out my .theia-ide settings folder, including the installed "github-authentication" vscode extension. The workflow works fine 🤷
Closing, as this works on the desktop now.