Closed shreya-groot closed 3 years ago
Handing the token back to your app is handled on Android by this activity tag in the AndroidManifest.xml (excerpt from the plugin.xml file of cordova-plugin-msal)
<activity
android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:scheme="msauth"
android:host="$PACKAGE_NAME"
android:path="/$KEY_HASH" />
</intent-filter>
</activity>
You'll need to make sure that the package name and the hash value are correct. Additionally there are some new security rules on Android that may prevent the app from getting the token in some cases. More info here : https://developer.chrome.com/docs/multidevice/android/intents/
This is my AndroidManifest.xml
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="io.ionic.starter" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:host="******" android:path="/smM2tjgTjUI********" android:scheme="msauth" />
</intent-filter>
</activity>
<provider android:authorities="${applicationId}.cordova.plugin.camera.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
</provider>
</application>
<uses-permission android:name="android.permission.INTERNET " />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE " />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
I found that my package name and key value is correct...I am not able to get the token in first attempt after sign in....Please help me to figure out the problem with my android app.
When I tried to login with the code above popup get opened, but after filling the credentials it does not take me back to my Android app at first attempt .After that on closing the login popup once and clicking the above function again will open the popup and after filling the credentails again in it, it ask me to continue and direct me back to the android app with the token generated.
My question is: Why my app didn't get token immediately after filling the credential in first attempt?