Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

Commit 3fe79b5

Browse files
author
Pat Patterson
committed
Only try token refresh on 401 error
1 parent 85dcad6 commit 3fe79b5

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

forcetk.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,17 @@ if (forcetk.Client === undefined) {
154154
processData: false,
155155
data: payload,
156156
success: callback,
157-
error: (!this.refreshToken || retry ) ? error : function() {
158-
that.refreshAccessToken(function(oauthResponse) {
159-
that.setSessionToken(oauthResponse.access_token, null,
160-
oauthResponse.instance_url);
161-
that.ajax(path, callback, error, method, payload, true);
162-
},
163-
error);
157+
error: (!this.refreshToken || retry ) ? error : function(jqXHR, textStatus, errorThrown) {
158+
if (jqXHR.status === 401) {
159+
that.refreshAccessToken(function(oauthResponse) {
160+
that.setSessionToken(oauthResponse.access_token, null,
161+
oauthResponse.instance_url);
162+
that.ajax(path, callback, error, method, payload, true);
163+
},
164+
error);
165+
} else {
166+
error(jqXHR, textStatus, errorThrown);
167+
}
164168
},
165169
dataType: "json",
166170
beforeSend: function(xhr) {

0 commit comments

Comments
 (0)