Skip to main content
Best answer

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


carlosatconnex

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)

Best answer by ikbelkirasanBest answer by ikbelkirasan

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
Did this topic help you find an answer to your question?
100% found this helpful
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

ikbelkirasan
Forum|alt.badge.img+12
  • Zapier Expert
  • 555 replies
  • Answer
  • April 4, 2021

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;
});

 


carlosatconnex
ikbelkirasan wrote:

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.