Skip to content

Commit

Permalink
Only try token refresh on 401 error
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Patterson committed May 25, 2011
1 parent 85dcad6 commit 3fe79b5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions forcetk.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,17 @@ if (forcetk.Client === undefined) {
processData: false,
data: payload,
success: callback,
error: (!this.refreshToken || retry ) ? error : function() {
that.refreshAccessToken(function(oauthResponse) {
that.setSessionToken(oauthResponse.access_token, null,
oauthResponse.instance_url);
that.ajax(path, callback, error, method, payload, true);
},
error);
error: (!this.refreshToken || retry ) ? error : function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 401) {
that.refreshAccessToken(function(oauthResponse) {
that.setSessionToken(oauthResponse.access_token, null,
oauthResponse.instance_url);
that.ajax(path, callback, error, method, payload, true);
},
error);
} else {
error(jqXHR, textStatus, errorThrown);
}
},
dataType: "json",
beforeSend: function(xhr) {
Expand Down

0 comments on commit 3fe79b5

Please sign in to comment.