'How to login using openid in VSCode extension?
I need some inputs/suggestions on how to login into VSC extension. I have already done similar stuff for web application in angular using https://www.npmjs.com/package/angular-auth-oidc-client library.
I am developing VSC extension(typescript language) in which I have to authenticate users before they use it. For that, I have cloudIDP auth URL to which I have to forward the request for users to get logged in first. Once user is logged in, Users should come back to VSC extension and then start using in-built extension commands.
I am using https://www.npmjs.com/package/openid-client library with code flow. I am able to open login url, getting users loggedin, coming back to vscode extension but without token.
let req = Client.authorizationUrl({
client_id: 'CLIENT:ID',
client_secret: 'CLIENT_SECRET',
redirect_uri: 'vscode://EXTENSION_NAME/auth',
scope: 'openid profile email offline_access',
response_type: ['code'],
code_challenge,
code_challenge_method: 'S256',
});
//This opens browser window from vscode and user gets logged in and comes back to extension
vscode.env.openExternal(vscode.Uri.parse(req)).then((response) => {
console.log('Signin response: ', response); // returns true
// not sure how to proceed here
});
Is my approach right or do I need to do anything else here ?
Please guide me, Thanks in advance.
Alpesh
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
