Last night I fetched some data using the below GET request

const result = await axios({
            method: 'get',
            url: `https://tahina-test2-dev-ed.my.salesforce.com/services/data/v48.0/query?q=SELECT+Product2Id,+Product2.Name+from+Pricebookentry+WHERE+Pricebook2Id='01s2X000002X6PxQAK'`,
            headers: {
                    'Bearer 00D2X000001esWS!ASAAQG1hpJDqk71EfwEsDjQEOIVpxLK6B86D8g3yhU5tlUWBtcHoZhpbCtu.kinCTNz03pmHu4xgE_WN05YihmiORJ8e01tZ'

But today I cannot fetch the same data as last night as token has expired. So my question is, is there anyway I can keep the token from expiring or getting a new token everytime it expires from my web app? I am using React JS to make this Get call if it helps.

Thank you!


Use the Web Server OAuth Flow, and include the refresh_token scope. When your access token expires, you use the Refresh Token FLow to get a new session. Use this only when you get a 403 error, rather than calling it every time you need to make an API call.

  • Thanks for the answer mate. I had to make a small directional change. I am not using JSforce to connect and query SF data into my react app. For this I am using node express on the backend and ran into an issue. Could you maybe help me out here salesforce.stackexchange.com/questions/311510/…? :) – Kisho Jul 2 '20 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.