我正在尝试为Ionic应用程序实现OAuth2 这是我登录的:
<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>
这是我的登录控制器:
'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");
};
})
我还将这些行添加到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>
虽然我已经添加了cordova-plugin-inappbrowser,因为我使用'离子服务',我可以在浏览器中看到正确的结果但是因为我使用'离子模拟android',在android模拟器中,没有任何反应,因为我点击我的登录按钮。 我在这里想念的是什么?