Question

Server 500 error when doing a refresh token

  • 20 July 2021
  • 0 replies
  • 144 views

Userlevel 1

I have a Platform app that I am creating. On the OAuth2.0 login when I am running a refreshtoken sometimes the response that I get back is a 500 error (I do not have control over the server that returns that error). This end up with the connection getting disconnected and all Zaps will stop (account has expired Please reconnect here.). Is there a way that within the refreshtoken code (Below) I could make the the refresh token try again if it receives a 500 error?

 

 

 

const options = {
url: 'https://auth.XXXXXXXX.com/oauth/token',
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
'accept': 'application/json'
},
body: {
'grant_type': 'refresh_token',
'refresh_token': bundle.authData.refresh_token,
'client_secret': bundle.authData.clients_secret,
'client_id': bundle.authData.clients_id
}
}
return z.request(options).then((res) => z.JSON.parse(res.content))
.then((json) => {
var access_token = json.access_token,
refresh_token = json.refresh_token;
const promise = z.request({
url: 'https://rest.XXXXXXXXXXXX.com/rest-services/login?version=2.0',
method: 'POST',
headers: {
'Content-Type':'application/x-www-form-urlencoded',
'Accept':'application/json'
},
body: {
'access_token':access_token
}
});
return promise.then((res) => z.JSON.parse(res.content))
.then((json) => {
return {
access_token: access_token,
refresh_token: refresh_token,

url: json.restUrl,
client_id: bundle.inputData.clients_id,
client_secret: bundle.inputData.clients_secret,
name: bundle.inputData.name
};
});
});

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.