2

I'm using MSAL in a react based SPA and a PCF component which is imported into a canvas app and this canvas app is embedded into Dynamic365 Field service CRM. I have created a Azure AAD app registration and added these redirectUri in Single Page Application

  1. localhost:3001
  2. *.crm.dynamics.com/main.aspx //main.aspx because i referenced this Issue #190 earlier.

So when i open my app in localhost:3001, it work fine. It popup a login window ask for login and when close it gives a access token in response. but in second condition pop up is not redirecting back to it's main page but opens in the popup itself.

I have used this inside PCF component which i am using in D365 Field service.

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

const msalConfig = {
  auth: {
    clientId: 'client_id',
    authority: 'https://login.microsoftonline.com/tanent_id',
    redirectUri: '*.crm.dynamics.com/main.aspx',
  }
};

const msalInstance = new PublicClientApplication(msalConfig);

var loginRequest = {
  responseMode:"query",
  scopes: ["openid", "offline_access", "https://storage.azure.com/user_impersonation"],
};


msalInstance.loginPopup(loginRequest)
  .then(response => {
    console.log(response)
  })
  .catch(err => {
    console.log(err)
  });

Reproduction Steps

  1. Create a PCF component with above Code Snippets.
  2. Add this PCF component inside a canvas app.
  3. Embed new created canvas app inside a D365 Field Service CRM.
  4. When you open your PCF component inside the D365 Field Service CRM which runs on this *.crm.dynamics.com/main.aspx, It will open a login Popup. we have to login from that popup.
  5. This popup does not close but open the redirect URL inside the popup only. enter image description here and I have added redirect URI inside App registration like this enter image description here

I have already used every variant like *.crm.dynamics.com/main.aspx and *.crm.dynamics.com/ and *.crm.dynamics.com.

Expected Behavior

A login popup pops up and after the user logs in the pop up closes itself and the loginPopup promise resolves (or rejects).

Actual Behavior

A login popup pops up and after the user logs in the pop up redirects back to my site in the pop up.

enter image description here

Dhruvil Dave
  • 109
  • 1
  • 20

0 Answers0