Search code examples
google-chrome-extensionmicrosoft-edgemicrosoft-edge-extension

Chrome Extension crashes the Microsoft Edge browser while calling launchWebAuthFlow API


We have a chrome extension that runs on Chromium edge and Chrome browser. Before today it was working all fine but today it starts crashing the Microsoft Edge after calling the API and while debugging we see the error comes from this API :

https://developer.chrome.com/docs/extensions/reference/identity/#method-launchWebAuthFlow

We use this API for auth and Microsoft also states that we can use this API. The below message is from the Microsoft channel :

chrome.identity.getAuthToken - As an alternate, you may use launchWebAuthFlow to fetch an OAuth2 token to authenticate users.

The issue is only coming with the edge browser. Edge Version : 96.0.1054.41 (Official Build) (64-bit) We also tried to downgrade the edge but nothing seems to be working.

We use Google and Microsoft login and launchwebauthflow is failing only on Microsoft login, the auth URI we are using: https://login.microsoftonline.com/common/oauth2/authorize

We are passing all the required parameters and the call is made from the background script.


Solution

  • We have finally changed the call and used chrome.windows.create api to initiate the authentication request

    return await global.chrome.windows.create({
        focused: true,
        height : 800,
        width: 800,
        url: authURL
    })
    

    We listened to the chrome page URL change and parse the token from the redirect URI and create a local token for the APIS.

    Here authurl is the same which we used for launchWebAuthFlow