Azure AD App Redirect URI for Chrome Exntension

后端 未结 2 494
庸人自扰
庸人自扰 2021-01-16 16:46

I\'m using the Microsoft Authentication Library for JavaScript (MSAL.js) version 1.3.2 in my chrome extension built on React JS. I have two login scenario I nee

2条回答
  •  独厮守ぢ
    2021-01-16 17:15

    I got this to work by just simply using the Chrome Identity API as shown below:

    var redirectUrl = chrome.identity.getRedirectURL()
    
    /*global chrome*/
    chrome.identity.launchWebAuthFlow(
      {
        url: 'https://login.microsoftonline.com//oauth2/v2.0/authorize?' +
          'response_type=token' +
          '&response_mode=fragment' +
          `&client_id=Azure AD Application Client ID` +
          `&redirect_uri=${redirectUrl}` +
          '&scope=openid https://management.azure.com/user_impersonation profile',
        interactive: true
      },
      function (responseWithToken) {
          // the access token needs to be extracted from the response.
      }
    );
    

    Additionally, you need to add Identity to permissions in the manifest.js, which is well documented here: https://developer.chrome.com/apps/app_identity

提交回复
热议问题