What redirect to use with MSAL for a Chrome extension?

Viewed 1067

I'm writing a Chrome extension that needs to access an ASP.NET Core web API that demands an AAD access token. I'm trying to use the msal NPM package to offer an auth flow so the user can sign in to my extension with their existing AAD account, thereby giving my extension the access token it needs.

I got so far as a popup window that signs the user in, but before my extension gets the token, the popup window displays this error:

ERR_UNSAFE_REDIRECT

I'm guessing this is because an https page is trying to redirect back to a URL with a chrome-extension:// scheme. But how should I do it? This is the code I have now:

    var userAgentApplication = new Msal.UserAgentApplication(applicationConfig.clientId, applicationConfig.authority, authCallback, {
        redirectUri: chrome.extension.getURL('popup.html'),
        cacheLocation: 'localStorage',
    });
    const idToken = await userAgentApplication.loginPopup(applicationConfig.scopes);
1 Answers

I found out that I need to add the html page used in redirectUri to the web_accessible_resources array in my manifest.json file, as documented here.

Related