I'm trying to integrate my Ionic/Capacitor
app with Microsoft Authentication Library (Msal), and unfortunately I couldn't found any Capacitor plugin for that, only found this Cordova plugin with its Ionic wrapper.
So I've followed the instructions of how to use Cordova plugins with capacitor according with the instructions of the plugin itself, but unfortunately with no success.
The problem is in the cordova plugin not being executed:
cordova.exec(successCallback, errorCallback, 'MsalPlugin', 'msalInit', [JSON.stringify(options)]);
because cordova.js
is not exist. Although I added the cordova.js
and cordova_plugin.js
in index.html
, but still the cordova.js
file is empty when use chrome://inspect
.
Also cordova.js
is exist in android\app\src\main\assets
but it seems like it's an old version that is not containing the method androidExec()
which is being called when try on another Ionic/Cordova
app. But even this version not exist when run application on emulator.
The msal Cordova plugin added with commands:
npm i --save cordova-plugin-msal
and
npm i --save ionic-msal-native
Platforms Android
package.json dependencies:
"dependencies": {
"@angular/common": "~12.1.1",
"@angular/compiler": "~12.1.1",
"@angular/core": "~12.1.1",
"@angular/forms": "~12.1.1",
"@angular/platform-browser": "~12.1.1",
"@angular/platform-browser-dynamic": "~12.1.1",
"@angular/router": "~12.1.1",
"@capacitor/android": "^3.1.2",
"@capacitor/cli": "^3.1.2",
"@capacitor/core": "^3.1.2",
"@ionic/angular": "^5.5.2",
"cordova-plugin-msal": "^2.5.0",
"ionic-msal-native": "^0.1.0",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 3.1.2
@capacitor/core: 3.1.2
@capacitor/android: 3.1.2
@capacitor/ios: 3.1.2
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/core: 3.1.2
@capacitor/cli: 3.1.2
@capacitor/android: 3.1.2
[success] Android looking great!
npm --version
: 6.14.14
node --version
: v14.17.4
was i missing something or made something wrong?