i want application send request backend , need base authentication. have following code:
myapp.factory('apirequest', ['$http', 'accountservice', function($http, accountservice) { var apiurl = 'https://web.appspot.com/_ah/api/server'; var apiver = 'v1'; var url = apiurl + '/' + apiver; return { getmessages: function(time_offset) { var encodedcredentials = accountservice.generatebase64credentials(); // $http.defaults.headers.common['authorization'] = encodedcredentials; tried this, doesn't work return $http.get( url + '/message', { headers: { 'authorization': accountservice.generatebase64credentials() }, params: { recipient_id: '6305746161500160', recipient_type: 'circle', time_offset: time_offset ? time_offset : null } } ) } } }]); unfortunately every time obtain authorization header:
basic w29iamvjdcbpymply3rdoltvymply3qgt2jqzwn0xq== my function accountservice.generatebase64credentials return string: basic window.btoa(login:password), why work way? how can make work properly
your input base64 encoding incorrect. when have decoded string, returning "[object object]:[object object]" (excluding double quotes). please check input "window.btoa" function first.
Comments
Post a Comment