Creating authentication RESTFUL - HTTP digest

Hello, I have an application developed using ionic, this application communicates through RESTFUL with a Back-End Java application, I would like to know how I can use a form of authentication to ensure the security and privacy of the accessed URIs, I intend to implement the HTTP digest, but I have no idea how to do this on the client side with ionic framework.
Would anyone know how I can do this, or know some stuff that I search.

Need the same. I want use digest authentication in ionic framework. Can anybody help me?

Got it. Solved!!!

incude the following js file in your index.html

http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/md5.js//for CryptoJS.MD5

.controller('Ctrl', function($scope, $http){
     var method = 'GET';
     var digestURI = 'YOUR URI'; example : "/flipkart/home.html"
     
     function makeid(vHere){
                var text = "";
                var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
                
                for( var i=0; i < vHere; i++ )
                      text += possible.charAt(Math.floor(Math.random() * possible.length));
                return text;
     }
     

  var nc = '0000000' + makeid(1);  
     var cnonce = makeid(8);

     $scope.getRResponse = function (nonce, realm, qop) {

               //if you qop = "auth-int" response will be calculated in different way follow   https://bitbucket.org/javarosa/javarosa/wiki/AuthenticationAPI 


               var HA1 = CryptoJS.MD5 ($scope.username + 
                                      ":" + realm + ":" + $scope.password);

               var HA2 = CryptoJS.MD5 (method + ":" + digestURI);
               return CryptoJS.MD5 (HA1 + 
                      ":" + nonce + ":" + nc + ":"+ cnonce + ":" + qop + ":" + HA2); 
    }

    $scope.sendRequestForFormsWithHeader = function (nonce, realm, qop){

          var response = $scope.getRResponse (nonce, realm, qop);
          var auth = 'Digest username="'+ $scope.username +'", 
                          realm="'+realm+'", 
                          nonce="'+nonce+'", 
                          uri="'+digestURI+'", 
                          response="'+response+'", 
                          qop='+qop+', 
                          nc='+nc+', 
                          cnonce="'+cnonce+'"';
          var config = {
                   headers: {     
                          Authorization: auth
                   }   
          };

          $http.get'YOUR URL WHICH GIVES 401 ERROR', config)

          .success(function(data, status, headers, config) {
                   console.log (data);     
          })
         .error(function(data, status, headers, config) {
               console.log("error");
          });
  };




    //Call this method first, in the error call back call the above method
        $scope.sendRequestForForms = function (){
               $http.get('YOUR URL WHICH GIVES 401 ERROR'**)
               .success(function(data, status, headers, config) {
                         console.log (data);
               })
               .error(function(data, status, headers, config) {
                   if(status === 401){
                          var headerHere = headers('WWW-Authenticate');
                          var nonce = headerHere.split('nonce=')[1];
                          nonce = nonce.substring(1, nonce.length - 1);
                          var realm = headerHere.split('realm="')[1];
                          realm = realm.split('"')[0];
                          var qop = headerHere.split('qop="')[1];
                          qop = qop.split('"')[0];
                          $scope.sendRequestForFormsWithHeader(nonce, realm, qop);
                   }else{
                          console.log (status);
                   }
        });

  };

})

Send opaque if your server send it in the header

If above code is confusing, you can post your code, I may help you

my email id rkpradhan@outlook.com