Best answer

Handle 403 Error as 401 (auto refresh acess token) [Oauth 2 , Platform UI ]

  • 4 April 2021
  • 2 replies
  • 56 views

Userlevel 1

Im doing a GoToWebinar integration to get some data that´s not included in the native app and i need.
My auth is working for the first token but is not refreshing so i get promted to re-auth after 60 mins and my zaps get turned off, i noticed im getting a “403” error instead of a “401” so i guess i need to handle it manually??


Q: does anybody has some snippet/example to handle a 403 error as 401 in zapier´s platform UI ?

**The objective is to trigger the Refresh Token request  when i get a 403 error (instead of a 401)

icon

Best answer by ikbelkirasan 4 April 2021, 04:48

Hi @carlosatconnex - Try handling it like so:

return z.request(options).then((response) => {
if (response.status === 403) {
throw new z.errors.RefreshAuthError();
}
response.throwForStatus();
return response.json;
});

 

View original

2 replies

Userlevel 7
Badge +11

Hi @carlosatconnex - Try handling it like so:

return z.request(options).then((response) => {
if (response.status === 403) {
throw new z.errors.RefreshAuthError();
}
response.throwForStatus();
return response.json;
});

 

Userlevel 1

Hi @carlosatconnex - Try handling it like so:

return z.request(options).then((response) => {
if (response.status === 403) {
throw new z.errors.RefreshAuthError();
}
response.throwForStatus();
return response.json;
});

 

Thank you very much @ikbelkirasan, this is spot on.


I added this snippet (excluding the “return response.json;”, since i´m already doing some parsing) to the desired Action API Endpoint (where i was getting the 403 error) and now the Refresh Token Request is actually invoked when i get the 403 error after the Access_Token expires and the Custom App connection is no longer lost.
 

Reply