I have implemented adal.js in my crm custom solution to call power bi rest api. When the token expires it is asking for login again with active directory login page. But I don't want this scenario. Since user already logged in into my dynamic crm online tenant so user should also be logged in into ADAL. It is really a cumbersome that user need to login again with anther login prompt to see the power bi report.
Is it possible to implement single sign with adal.js into my dynamic crm online tenant? Below is my current code using adal.js:
var adalConfig = {
clientId: POWER_BI_APP_ID,
popUp: true,
cacheLocation: "localStorage",
redirectUri: 'test.crm6.dynamics.com'
};
var adalAuthContext = new window['AuthenticationContext'](adalConfig);
var user = adalAuthContext.getCachedUser();
if (!user) {
adalAuthContext.login();
}
if (adalAuthContext.isCallback(window.location.hash)) {
adalAuthContext.handleWindowCallback();
}
adalAuthContext.acquireToken(resourceUrl, function (errorDesc, token, error) {
if (error) {
//acquire token failure
if (adalConfig.popUp) {
// If using popup flows
adalAuthContext.acquireTokenPopup(resourceUrl, null, null, function (errorDesc, token, error) { });
}
else {
// In this case the callback passed in the Authentication request constructor will be called.
adalAuthContext.acquireTokenRedirect(resourceUrl, null, null);
}
}
else {// success}
});
*This post is locked for comments
I have the same question (0)