Alain ANDRE Alain ANDRE - 5 months ago 19
AngularJS Question

Facebook token auth fails on Android but not browsers

I'm building an ionic app and I'm using ng-token-auth. Everything is fine in a browser, I can identify via Facebook, but when I emulate on android, I got an error after I get logged into Facebook and the app is redirecting :

I/chromium( 2252): [INFO:CONSOLE(0)] "Not allowed to load local resource: file:///android_asset/www/index.html?auth_token=kUDlceeLBDmauQ2nN_KzqQ&blank=true&client_id=zoIcXXXXolEkpN0IxM9utA&config=&expiry=1459541228&uid=1727512764150849#/app/signin", source: file:///android_asset/www/index.html#/app/signin (0)


Here is my back-end code:

BASE_API_URL
depends if the app is launched on locahost or not.

$authProvider
.configure({
apiUrl: BASE_API_URL,
storage: 'localStorage',
forceHardRedirect: true,
omniauthWindowType: window.cordova == undefined ? 'sameWindow' : 'inAppBrowser',
authProviderPaths: {
facebook: '/auth/facebook'
}
})


My config.xml has the inAppBrowser feature.

<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser"/>
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
</feature>


Any idea ? does it have to do something with webview ? Or is it the Content-Security-Policy ? I use InAppBrowser feature, but how could I be sure it's launched with ?

Answer

Ok, I solved it. It was due to omniauthWindowType: window.cordova == undefined ? 'sameWindow' : 'inAppBrowser' that always used sameWindow.