Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android AngularJS$http请求API维护身份验证数据_Android_Angularjs_Caching_Ionic Framework_Basic Authentication - Fatal编程技术网

Android AngularJS$http请求API维护身份验证数据

Android AngularJS$http请求API维护身份验证数据,android,angularjs,caching,ionic-framework,basic-authentication,Android,Angularjs,Caching,Ionic Framework,Basic Authentication,我正在编写基于Ionic/Cordova的应用程序,该应用程序需要使用外部API,其中必须提供身份验证数据(通过http基本头) 问题是应用程序维护授权(在提供正确的凭据之后),而我无法注销(强制应用程序阻止对API的访问) HTTP身份验证验证机制: var validateCredentials = function(user, password, callback) { var req = { method: 'GET', url: 'http:/

我正在编写基于Ionic/Cordova的应用程序,该应用程序需要使用外部API,其中必须提供身份验证数据(通过http基本头)

问题是应用程序维护授权(在提供正确的凭据之后),而我无法注销(强制应用程序阻止对API的访问)

HTTP身份验证验证机制:

var validateCredentials = function(user, password, callback) {

    var req = {
        method: 'GET',
        url: 'http://server.host.com/api/check?Accept=application/json',
         headers: {
            'Authorization': 'Basic ' + btoa(user + ':' + password)
         }
    };

    $http(req).success(function(data) {
        callback(true);
    }).error(function(error) {
        callback(false);
    });
}
我的用例:

1) 我向方法提供了错误的凭据,并收到401(这很好):

2) 然后我提供正确的凭证并收到200 OK(这也很好):

3) 最后,如果在API仍在工作时再次提供错误的凭据(200而不是401):

因此,我无法从我的应用程序中注销,而且-我无法登录到其他用户

我试图清除缓存、ionic history和webview缓存,但仍然没有成功。清除会话/身份验证数据的唯一选项是Andoird OS设置/应用程序/清除应用程序数据

最后,应用程序上下文中没有cookie或会话变量(至少根据我的设备在调试模式下运行的Chrome Developer console)

任何提示,谢谢