Question

Stale Auth triggers when it should refresh the session token

  • 11 January 2022
  • 1 reply
  • 25 views

Userlevel 1

Hello everyone,

I’m running into some trouble with polling triggers specifically and refreshing the token on Session Auth. Every hour the token expires and the server returns back a 401 error to Zapier. In most cases Zapier calls the Session Auth automatically and a new token is issued, however, if multiple polling triggers are set up and they each get 401 error codes then Zapier will throw a stale auth error and the user will have to re-connect their App again. I would like Zapier to not throw the Stale Auth error unless something changed on their account (i.e. Username or Password change).

Below is a snippet of code that my polling trigger runs when it receives a response from the server. 

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

I used response.throwForStatus(); initially and then decided to try z.errors.RefreshAuthError(); if the response is a 401. However I’m still getting the stale auth. Just wanted to see if anyone had a similar problem and has a solution. 


1 reply

Userlevel 1

Adding to this, here is a response from Zapier after receiving a 401 from our server.

 

Unhandled error: ResponseError: {"status":401,"headers":{"content-type":"text/plain; charset=utf-8"},"content":"Token is invalid, request new token.","request":{"url":"https://lightning.yourassociation.org/api/IQA"}}
ResponseError: {"status":401,"headers":{"content-type":"text/plain; charset=utf-8"},"content":"Token is invalid, request new token.","request":{"url":"https://lightning.yourassociation.org/api/IQA"}}
at throwForStaleAuth (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-stale-auth.js:11:11)
at Object.collector.then.newOutput (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:80:37)
From previous event:
at afters.reduce (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:77:26)
at Array.reduce (<anonymous>)
at afterMiddleware (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:76:21)
at Object.resolve.then.then.output (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:94:18)
From previous event:
at Object.beforeMiddleware.then.newInput (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:92:10)
From previous event:
at input (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/middleware.js:89:45)
at loadApp.then.appRaw (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:216:18)
at bound (domain.js:402:14)
at runBound (domain.js:415:12)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
at Domain.handlerDomain.run (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:200:10)
at Domain.run (domain.js:349:14)
at Runtime.handler (:censored:9:d1ba0cf2aa:/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:192:19)
at Runtime.handleOnce (:censored:12:bb66ff632a:/Runtime.js:66:25)

 

Reply