I'm trying to have an OAuth2 implemented for Ionic application This is my login for:
<ion-view view-title="Login" align-title="left">
<ion-nav-bar class="bar-positive">
<ion-nav-back-button class="button-clear icon ion-ios7-arrow-back">
</ion-nav-back-button>
</ion-nav-bar>
<ion-content class="padding">
<img src="img/Exact_Logo.jpg" border="0"></a><br/>
<a class="button icon-right ion-chevron-right" ng-click="loginToFoo()">Sign in with Foo Account</a>
</div>
</ion-content>
and this is my login controller:
'use strict';
angular.module('fooapp')
.controller('loginCtrl', function($scope, $state, $http) {
$scope.signIn = function(user) {
console.log('Sign-In', user);
$state.go('tab.home');
}
$scope.loginToFoo = function() {
var URL_AUTH = 'https://foo.com/api/oauth2/auth';
var RESPONSE_TYPE_CODE = 'code';
var CLIENT_ID = '{xxxxxx-xxxxx-xxxxx-xxxxx}';
var REDIRECT_URL = 'http://localhost/callback';
var loginUrl = URL_AUTH + '?client_id=' + CLIENT_ID +
'&redirect_uri=' + REDIRECT_URL +
'&force_login=1&response_type=' + RESPONSE_TYPE_CODE ;
window.open(loginUrl, "_system", "location=yes");
};
})
I have also added these lines to config.xml:
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
Although I have already added cordova-plugin-inappbrowser, as I use 'ionic serve', I can see the correct result in a browser but as I use 'ionic emulate android' or run it on device, after login I receive following error:
I understand that "http://localhost" is not the device root for application but I don't know I should change it to what exactly.