salesforce-marketingcloud / FuelSDK-Node-REST

Node REST client w/ auth to access the Salesforce Marketing Cloud (formerly ExactTarget) API
BSD 3-Clause "New" or "Revised" License
43 stars 22 forks source link

Retry doesn't help #76

Closed jaypeng2015 closed 6 years ago

jaypeng2015 commented 7 years ago

Version: 2.0.5

On get | post | put | patch | delete requests, the retry options is true by default. Ideally this will re-fetch the access token and make the request again after receiving a 401 error.

However, by the following logic in _processRequest function, the Authorization header will only be updated when it doesn't exist, which means the second request will still take the old token and then always get a 401 error again.

if (!options.headers.Authorization) {
    options.headers.Authorization = 'Bearer ' + authResponse.accessToken;
    retry = options.retry || false;
}
vernak2539 commented 7 years ago

@nathan-boyd do you remember why we did this? Or @dougwilson ??

jaypeng2015 commented 6 years ago

It's been almost year now and I still have to use invalidateToken and resend the request again on 401, with the latest sdk version... :(

vernak2539 commented 6 years ago

@jaypeng2015 I'm sorry about that. Since I did not get any response about this, would you mind submitting a PR with the requested changes? I can then get a new version out for you

jaypeng2015 commented 6 years ago

@vernak2539 I have created a PR however the CI fails because the project doesn't support Node 10.

vernak2539 commented 6 years ago

I will take a look at it and try to get it working.

Edit: the stable version seems to have changed since the last master run, from v9 to v10. Will have a look