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 extension UriHandlers #19

Open
TylerLeonhardt opened this issue Jan 4, 2022 · 4 comments
Open

Support extension UriHandlers #19

TylerLeonhardt opened this issue Jan 4, 2022 · 4 comments

Comments

@TylerLeonhardt
Copy link
Member

In a vscode extension you can register a URI handler:
https://code.visualstudio.com/api/references/vscode-api#UriHandler

This UriHandler will get invoked when an external webpage redirects into VS Code with the extension identifier specified.

This works in vscode.dev (thanks to @joaomoreno) where the server sets up a well-known route (vscode.dev/callback) that handles requests that will turn around and invoke registered UriHandlers. Note, this works in tandem with vscode.env.openExternal which will give you the exact Uri to redirect into.

vscode-test-web should have a similar capability and I feel like a lot of the logic can be shared.

Additionally, the Microsoft and GitHub auth extensions use UriHandler for logging in so this means that extensions that use our in-box auth extensions can not be tested in vscode-test-web either.

Workaround

Sideloading the extension on vscode.dev works around this and still allows the author to test their extension on web.

@aeschli
Copy link
Contributor

aeschli commented Jan 11, 2022

@TylerLeonhardt I'm new to the callback, and don't know how the flow works. I (blindly) adopted what @bpasero did in microsoft/vscode#140329. Can you test it out? (Maybe add some steps so I get an idea how to test it myself)

It's just in source, not yet published -> use yarn link.

If I understand this right, ideally this could go to callback.html and no server code is needed.

@bpasero
Copy link
Member

bpasero commented Jan 12, 2022

There is still a little server dependency to serve callback.html, replace some variables and set the proper content security policy. But it is true that the change I pushed for callbacks makes the flow state less, where before the server had to keep callbacks in memory (now they are in local storage of the client).

@aeschli
Copy link
Contributor

aeschli commented Feb 3, 2022

In the meantime we've adopted the new fully serverless callback.html.

@TylerLeonhardt Is the more needed to get the auth flow running in vscode-test-web as well?

Currently, when I try the github authentication flow, I end up with the Enter Github Auth Token quick input.

@TylerLeonhardt
Copy link
Member Author

@aeschli GitHub auth doesn't work with localhost. You will have to try either Microsoft auth or I made a test extension for UriHandlers:
https://github.com/TylerLeonhardt/open-external

once you have it running locally, run the command: Open an external Uri and choose Trigger uri handler...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants