'How to open browser from vscode api, close it after response received and then return back to vscode application

I am developing a plugin in VSCODE and here is what I am trying to figure out

  1. From within plugin, open the browser with a url, do a sign in and get the response in vscode plugin and then close the browser.

I could do this by using

  1. vscode.window.createWebviewPanel - This will need a lot of duplicate code to be done on vscode plugin side.

OR could try below

  1. Use open lib npm - open the browser, but the challenge is I am not sure on how to close the browser and send response to VSOCODE plugin. Is it even possible in vs code ?


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source