cordova-plugin-ms-adal和iOS13的问题

问题描述 投票:0回答:1

[我们在iOS13上使用cordova-plugin-ms-adal进行AD Azure身份验证时遇到问题。这来自Cordova应用程序,打包并通过应用程序商店安装。它在iOS12和Android上正常运行,但在iOS13上却无提示地失败,导致“空白页”,因为没有触发任何回调。

下面是示例代码,来自插件文档页面以进行说明。 'acquireTokenSilentAsync'和'acquireTokenAsync'(如果直接调用)都将失败,但不会触发任何错误回调。

[我知道自从2019年3月起,Microsoft不再支持ADAL cordova插件,但是我试图确定该插件是否可以以某种方式与iOS13一起使用,或者我们是否必须切换到其他机制(例如MSAL)?

总之,有人可以确定是否可以将cordova-plugin-ms-adal插件制作为打包的cordova应用程序与iOS13一起使用,如果不能,那是一个好的替代品?

// Shows user authentication dialog if required
function authenticate(authCompletedCallback, errorCallback) {
  var authContext = new Microsoft.ADAL.AuthenticationContext(authority);
  authContext.tokenCache.readItems().then(function (items) {
    if (items.length > 0) {
        authority = items[0].authority;
        authContext = new Microsoft.ADAL.AuthenticationContext(authority);
    }
    // Attempt to authorize user silently
    authContext.acquireTokenSilentAsync(resourceUri, clientId)
    .then(authCompletedCallback, function () {
        // We require user credentials so triggers authentication dialog
        authContext.acquireTokenAsync(resourceUri, clientId, redirectUri)
        .then(authCompletedCallback, errorCallback);
    });
  });
};

authenticate(function(authResponse) {
  console.log("Token acquired: " + authResponse.accessToken);
  console.log("Token will expire on: " + authResponse.expiresOn);
}, function(err) {
  console.log("Failed to authenticate: " + err);
});
cordova ios13 adal msal msal.js
1个回答
0
投票

由于azure-activedirectory-library-for-cordova处于归档状态,不再受支持,因此最好将应用程序移至microsoft-authentication-library-for-js。您也可以在此存储库中找到此插件的AngularJS / Angular包装版本。这种实现方式与科尔多瓦方式类似。唯一的区别是您不需要将其添加为cordova插件,而需要添加为JS依赖项。

© www.soinside.com 2019 - 2024. All rights reserved.