Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions forceng.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ angular.module('forceng', [])
params: params
})
.success(function (data, status, headers, config) {
console.log('Token refreshed');
oauth.access_token = data.access_token;
tokenStore.forceOAuth = JSON.stringify(oauth);
deferred.resolve();
Expand Down Expand Up @@ -199,8 +198,6 @@ angular.module('forceng', [])
oauth.refresh_token = params.refreshToken;
}
}

console.log("useProxy: " + useProxy);
}

/**
Expand Down Expand Up @@ -305,7 +302,6 @@ angular.module('forceng', [])
* data: JSON object to send in the request body - Optional
*/
function request(obj) {

var method = obj.method || 'GET',
headers = {},
url = getRequestBaseURL(),
Expand Down Expand Up @@ -342,15 +338,17 @@ angular.module('forceng', [])
deferred.resolve(data);
})
.error(function (data, status, headers, config) {
if (status === 401 && oauth.refresh_token) {
if ((status === 401 || status === 403) && oauth.refresh_token) {
refreshToken()
.success(function () {
// Try again with the new token
request(obj);
})
.error(function () {
console.error(data);
deferred.reject(data);
.then(function() {
request(obj).then(function(data) {
deferred.resolve(data);
}, function(error) {
deferred.reject(error);
});
}, function(error) {
console.error(error);
deferred.reject(error);
});
} else {
console.error(data);
Expand Down