2017-01-22 02:00:25 +01:00
|
|
|
function ApiService(tokenService, logoutCallback) {
|
2017-01-20 01:21:22 +01:00
|
|
|
//this.baseUrl = 'http://localhost:4000';
|
2017-01-19 06:21:20 +01:00
|
|
|
this.baseUrl = 'https://api.bitwarden.com';
|
2016-09-03 06:38:27 +02:00
|
|
|
this.tokenService = tokenService;
|
2017-01-22 02:00:25 +01:00
|
|
|
this.logoutCallback = logoutCallback;
|
2016-09-04 06:34:24 +02:00
|
|
|
|
|
|
|
initApiService();
|
2016-09-03 06:38:27 +02:00
|
|
|
};
|
|
|
|
|
2016-09-04 06:34:24 +02:00
|
|
|
function initApiService() {
|
2016-09-03 21:44:32 +02:00
|
|
|
// Auth APIs
|
|
|
|
|
2017-01-19 04:14:51 +01:00
|
|
|
ApiService.prototype.postIdentityToken = function (tokenRequest, success, successWithTwoFactor, error) {
|
2017-01-18 05:07:46 +01:00
|
|
|
var self = this;
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: self.baseUrl + '/connect/token',
|
|
|
|
data: tokenRequest.toIdentityToken(),
|
|
|
|
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
|
|
|
success(new IdentityTokenResponse(response));
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-19 04:14:51 +01:00
|
|
|
if (jqXHR.responseJSON && jqXHR.responseJSON.TwoFactorRequired &&
|
|
|
|
jqXHR.responseJSON.TwoFactorRequired === true) {
|
|
|
|
successWithTwoFactor();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
error(new ErrorResponse(jqXHR, true));
|
|
|
|
}
|
2017-01-18 05:07:46 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-03 07:13:09 +02:00
|
|
|
// Account APIs
|
2016-09-03 18:07:30 +02:00
|
|
|
|
2017-01-14 18:47:11 +01:00
|
|
|
ApiService.prototype.getAccountRevisionDate = function (success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2017-01-14 18:47:11 +01:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/accounts/revision-date?access_token2=' + token,
|
2017-01-14 18:47:11 +01:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
|
|
|
success(response);
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2017-01-14 18:47:11 +01:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2017-01-14 18:47:11 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-03 06:38:27 +02:00
|
|
|
ApiService.prototype.getProfile = function (success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 06:38:27 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/accounts/profile?access_token2=' + token,
|
2016-09-03 06:38:27 +02:00
|
|
|
dataType: 'json',
|
2016-09-03 07:13:09 +02:00
|
|
|
success: function (response) {
|
2016-09-22 20:16:24 +02:00
|
|
|
success(new ProfileResponse(response));
|
2016-09-03 07:13:09 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 07:13:09 +02:00
|
|
|
}
|
2016-09-03 06:38:27 +02:00
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 06:38:27 +02:00
|
|
|
});
|
|
|
|
};
|
2016-09-03 07:13:09 +02:00
|
|
|
|
2016-09-20 23:47:21 +02:00
|
|
|
ApiService.prototype.postPasswordHint = function (request, success, error) {
|
|
|
|
var self = this;
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: self.baseUrl + '/accounts/password-hint',
|
2016-12-29 22:09:28 +01:00
|
|
|
dataType: 'text',
|
2016-09-20 23:47:21 +02:00
|
|
|
data: JSON.stringify(request),
|
2016-09-21 01:57:24 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2016-09-20 23:47:21 +02:00
|
|
|
success: function (response) {
|
|
|
|
success();
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-20 23:47:21 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-21 01:57:24 +02:00
|
|
|
ApiService.prototype.postRegister = function (request, success, error) {
|
2016-09-20 23:47:21 +02:00
|
|
|
var self = this;
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: self.baseUrl + '/accounts/register',
|
|
|
|
data: JSON.stringify(request),
|
2016-12-29 22:09:28 +01:00
|
|
|
dataType: 'text',
|
2016-09-21 01:57:24 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2016-09-20 23:47:21 +02:00
|
|
|
success: function (response) {
|
|
|
|
success();
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-20 23:47:21 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-01-14 17:20:44 +01:00
|
|
|
// Settings APIs
|
|
|
|
|
|
|
|
ApiService.prototype.getIncludedDomains = function (success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2017-01-14 17:20:44 +01:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/settings/domains?excluded=false&access_token2=' + token,
|
2017-01-14 17:20:44 +01:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
|
|
|
success(new DomainsResponse(response));
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2017-01-14 17:20:44 +01:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2017-01-14 17:20:44 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-01-04 00:40:07 +01:00
|
|
|
// Login APIs
|
2016-09-03 07:13:09 +02:00
|
|
|
|
2017-01-04 00:40:07 +01:00
|
|
|
ApiService.prototype.getLogin = function (id, success, error) {
|
2016-09-03 18:07:30 +02:00
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/sites/' + id + '?access_token2=' + token,
|
2016-09-03 18:07:30 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2017-01-04 00:40:07 +01:00
|
|
|
success(new LoginResponse(response));
|
2016-09-03 18:07:30 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-01-04 00:40:07 +01:00
|
|
|
ApiService.prototype.postLogin = function (loginRequest, success, error) {
|
2016-09-03 18:07:30 +02:00
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/sites?access_token2=' + token,
|
2017-01-04 00:40:07 +01:00
|
|
|
data: JSON.stringify(loginRequest),
|
2016-09-21 01:57:24 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2016-09-03 18:07:30 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2017-01-04 00:40:07 +01:00
|
|
|
success(new LoginResponse(response));
|
2016-09-03 18:07:30 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2017-01-04 00:40:07 +01:00
|
|
|
ApiService.prototype.putLogin = function (id, loginRequest, success, error) {
|
2016-09-03 18:07:30 +02:00
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/sites/' + id + '?access_token2=' + token,
|
2017-01-04 00:40:07 +01:00
|
|
|
data: JSON.stringify(loginRequest),
|
2016-09-21 01:57:24 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2016-09-03 18:07:30 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2017-01-04 00:40:07 +01:00
|
|
|
success(new LoginResponse(response));
|
2016-09-03 18:07:30 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-03 07:13:09 +02:00
|
|
|
// Folder APIs
|
|
|
|
|
2016-09-03 18:07:30 +02:00
|
|
|
ApiService.prototype.getFolder = function (id, success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/folders/' + id + '?access_token2=' + token,
|
2016-09-03 18:07:30 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2016-09-22 20:16:24 +02:00
|
|
|
success(new FolderResponse(response));
|
2016-09-03 18:07:30 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
|
|
|
});
|
2016-09-03 18:07:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.prototype.postFolder = function (folderRequest, success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/folders?access_token2=' + token,
|
2016-09-03 21:44:32 +02:00
|
|
|
data: JSON.stringify(folderRequest),
|
2016-09-21 01:57:24 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2016-09-03 18:07:30 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2016-09-22 20:16:24 +02:00
|
|
|
success(new FolderResponse(response));
|
2016-09-03 18:07:30 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.prototype.putFolder = function (id, folderRequest, success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/folders/' + id + '?access_token2=' + token,
|
2016-09-03 21:44:32 +02:00
|
|
|
data: JSON.stringify(folderRequest),
|
2016-09-21 01:57:24 +02:00
|
|
|
contentType: 'application/json; charset=utf-8',
|
2016-09-03 18:07:30 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2016-09-22 20:16:24 +02:00
|
|
|
success(new FolderResponse(response));
|
2016-09-03 18:07:30 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-03 07:13:09 +02:00
|
|
|
// Cipher APIs
|
2016-09-03 18:07:30 +02:00
|
|
|
|
2016-09-03 07:13:09 +02:00
|
|
|
ApiService.prototype.getCipher = function (id, success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 07:13:09 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/ciphers/' + id + '?access_token2=' + token,
|
2016-09-03 07:13:09 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
2016-09-22 20:16:24 +02:00
|
|
|
success(new CipherResponse(response));
|
2016-09-03 07:13:09 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 07:13:09 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 07:13:09 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
ApiService.prototype.getCiphers = function (success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 07:13:09 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/ciphers?access_token2=' + token,
|
2016-09-03 07:13:09 +02:00
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
|
|
|
var data = [];
|
2016-09-07 05:30:49 +02:00
|
|
|
for (var i = 0; i < response.Data.length; i++) {
|
|
|
|
data.push(new CipherResponse(response.Data[i]));
|
2016-09-03 07:13:09 +02:00
|
|
|
}
|
|
|
|
|
2016-09-22 20:16:24 +02:00
|
|
|
success(new ListResponse(data));
|
2016-09-03 07:13:09 +02:00
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 07:13:09 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 07:13:09 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2016-09-03 18:07:30 +02:00
|
|
|
ApiService.prototype.deleteCipher = function (id, success, error) {
|
|
|
|
var self = this;
|
2017-01-19 06:21:20 +01:00
|
|
|
handleTokenState(self).then(function (token) {
|
2016-09-03 18:07:30 +02:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
2017-01-18 05:07:46 +01:00
|
|
|
url: self.baseUrl + '/ciphers/' + id + '/delete?access_token2=' + token,
|
2016-12-29 22:09:28 +01:00
|
|
|
dataType: 'text',
|
2016-09-22 20:16:24 +02:00
|
|
|
success: function (response) {
|
|
|
|
success();
|
|
|
|
},
|
2016-09-03 18:07:30 +02:00
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, false, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
}
|
|
|
|
});
|
2017-01-19 06:21:20 +01:00
|
|
|
}, function (jqXHR) {
|
2017-01-22 02:00:25 +01:00
|
|
|
handleError(error, jqXHR, true, self);
|
2016-09-03 18:07:30 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
// Helpers
|
|
|
|
|
2017-01-22 02:00:25 +01:00
|
|
|
function handleError(errorCallback, jqXHR, tokenError, self) {
|
2017-01-19 06:21:20 +01:00
|
|
|
if (tokenError || jqXHR.status === 401 || jqXHR.status === 403) {
|
2017-01-22 02:00:25 +01:00
|
|
|
if (self && self.logoutCallback) {
|
|
|
|
self.logoutCallback(true, function () { })
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
chrome.runtime.sendMessage({ command: 'logout', expired: true });
|
|
|
|
}
|
|
|
|
|
2016-09-21 21:21:50 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-03 07:13:09 +02:00
|
|
|
errorCallback(new ErrorResponse(jqXHR));
|
|
|
|
}
|
2017-01-19 06:21:20 +01:00
|
|
|
|
|
|
|
function handleTokenState(self) {
|
|
|
|
var deferred = Q.defer();
|
|
|
|
self.tokenService.getToken(function (accessToken) {
|
|
|
|
if (self.tokenService.tokenNeedsRefresh()) {
|
|
|
|
self.tokenService.getRefreshToken(function (refreshToken) {
|
2017-01-22 02:00:25 +01:00
|
|
|
if (!refreshToken || refreshToken === '') {
|
|
|
|
deferred.reject();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-01-19 06:21:20 +01:00
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: self.baseUrl + '/connect/token',
|
|
|
|
data: {
|
|
|
|
grant_type: 'refresh_token',
|
|
|
|
client_id: 'browser',
|
|
|
|
refresh_token: refreshToken
|
|
|
|
},
|
|
|
|
contentType: 'application/x-www-form-urlencoded; charset=utf-8',
|
|
|
|
dataType: 'json',
|
|
|
|
success: function (response) {
|
|
|
|
var token = new IdentityTokenResponse(response);
|
|
|
|
tokenService.setTokens(token.accessToken, token.refreshToken, function () {
|
|
|
|
deferred.resolve(token.accessToken);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) {
|
|
|
|
deferred.reject(jqXHR);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
deferred.resolve(accessToken);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return deferred.promise
|
|
|
|
}
|
2016-09-04 06:34:24 +02:00
|
|
|
};
|