View difference between Paste ID: zsn9ASkM and h9tXT6GN
SHOW: | | - or go back to the newest paste.
1
var loginObj = {
2
  'username':   $scope.username,
3
  'password':   $scope.password,
4
  'grant_type': 'password',
5
  'client_id':  'web'
6
}
7
8
var doLogin = $http({
9
  method: 'POST',
10
  url: 'https://api/v1/token',
11
  headers: {'Content-Type': 'application/x-www-form-urlencoded'},
12
  transformRequest: function(obj) {
13
    var str = [];
14
    for(var p in obj) {
15
      str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
16
    }
17
    return str.join('&');
18
  },
19
  data: loginObj,
20
  responseType: 'json'
21
})
22
23
doLogin.then(
24
  onLoginSuccess,
25
  onLoginError
26
)