How to do login on VS Code extension

21 Views Asked by At

I have created a vs-code extension.

Basically I need to implement login for my vs-code extension.But there is already login implemented for my web app using azure AD.Let me first show the login flow for web app.

This is my auth config file

import { LogLevel } from "@azure/msal-browser";


export const msalConfig = {
    auth: {
        clientId: {clientId}, 
        authority: 'https://login.microsoft.com/3ad3552', 
        redirectUri: '/App', 
        postLogoutRedirectUri: '/',
        navigateToLoginRequestUrl: false, 
    },
    cache: {
        cacheLocation: 'localStorage',
        storeAuthStateInCookie: false,
    },
    system: {
        loggerOptions: {
            loggerCallback: (level, message, containsPii) => {
                if (containsPii) {
                    return;
                }
                switch (level) {
                    case LogLevel.Error:
                        console.error(message);
                        return;
                    case LogLevel.Info:
                        console.info(message);
                        return;
                    case LogLevel.Verbose:
                        console.debug(message);
                        return;
                    case LogLevel.Warning:
                        console.warn(message);
                        return;
                    default:
                        return;
                }
            },
        },
    },
};

export const loginRequest = {
    scopes: ["openid"],
};

As you can see, in the auth config once logged in i am redirecting to "/App".This is my web App login flow.

Now coming back to my vs-code extension,I have a simple login button. On click of that button, i am redirecting user from extension to my web app login page.

Now i need to know how to indicate to my login page, that it was tiggered from extension and once successful login redirecting back again to extension with user info.

For the first part, while redirecting i did like, "https://url.net/?source=vscode".

How to implement second part. If not code, just some guidance on flow would be helpful.

0

There are 0 best solutions below