microsoft-authentication-library-for-js: acquireTokenPopup doesn't work

I can’t make acquireTokenPopup to work. In Firefox it’s clearly blocked by the popup blocker, I get the notification and receive the error message: Could not retrieve token from popup. popup_window_error:Error opening popup window. This can happen if you are using IE or if popups are blocked in the browser.

In Chrome, the popup does show up, but then I get the same error message. In Edge, the popup shows up, disappears and I get the following error:

ERROR Error: Uncaught (in promise): Error
Error
   at Anonymous function (https://localhost:44388/dist/msal.js:1677:25)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at onInvoke (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:890)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at Zone.prototype.run (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111033:17)
   at Anonymous function (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111710:17)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at onInvokeTask (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:802)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at Zone.prototype.runTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111083:21)
vendor.js (8,349)
   "ERROR"
   {
      [functions]: ,
      __proto__: { },
      description: "Uncaught (in promise): Error
Error
   at Anonymous function (https://localhost:44388/dist/msal.js:1677:25)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at onInvoke (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:890)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at Zone.prototype.run (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111033:17)
   at Anonymous function (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111710:17)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at onInvokeTask (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:802)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at Zone.prototype.runTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111083:21)",
      message: "Uncaught (in promise): Error
Error
   at Anonymous function (https://localhost:44388/dist/msal.js:1677:25)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at onInvoke (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:890)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at Zone.prototype.run (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111033:17)
   at Anonymous function (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111710:17)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at onInvokeTask (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:802)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at Zone.prototype.runTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111083:21)",
      name: "Error",
      promise: {
         [functions]: ,
         __proto__: { },
         __zone_symbol__state: 0,
         __zone_symbol__value: { }
      },
      rejection: { },
      stack: "Error: Uncaught (in promise): Error
Error
   at Anonymous function (https://localhost:44388/dist/msal.js:1677:25)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at onInvoke (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:890)
   at ZoneDelegate.prototype.invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111281:13)
   at Zone.prototype.run (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111033:17)
   at Anonymous function (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111710:17)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at onInvokeTask (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:802)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at Zone.prototype.runTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111083:21)
   at resolvePromise (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111662:25)
   at Anonymous function (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111713:17)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at onInvokeTask (https://localhost:44388/dist/vendor.js?v=36fdSypR7HRyyaROCi65hZ58pj3rerCHNmsj_igK_Yg:36:802)
   at ZoneDelegate.prototype.invokeTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111314:13)
   at Zone.prototype.runTask (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111083:21)
   at drainMicroTaskQueue (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111476:25)
   at invoke (https://localhost:44388/dist/main-client.js?v=gybG-8xQhYvwdYX40BeY6Wh0n99qhFPDjIcp-UKcV8A:111382:25)",
      task: { },
      zone: { }
   }

Looks like there’s something wrong in the msal.js, but there’s not much about what exactly is the issue.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

@rohitnarula7176 OK, I got the whole project working, with a big help from @spottedmahn. The code pushed to https://github.com/Gimly/NetCoreAngularAzureB2CMsal is now working, client side and server side with the fabrikamb2c tenant.

Let me know (or directly add issues to the repo) if you want things changed or want me to do something to add it to your documentation.

Cheers.

@Gimly you are facing this issue because when you start your app at ‘http://localhost:6420’, angular routing redirects you to ‘http://localhost:6420/home’. When you click login from your home page, since you did not specify a redirectUri in your constructor, msal uses your window.location.href which is ‘http://localhost:6420/home’ and assigns it to the redirectUri for the authorization request. This results in a mismatch error because the registered redirectUri for your app in the portal is ‘http://localhost:6420’. To fix it, please change your constructor function in ‘authentication.service.ts’ to

this.clientApplication =
            new Msal.UserAgentApplication(
                environment.clientID,
                this.authority,
                this.authCallback,{redirectUri:'http://localhost:6420'});