My integration is working fine locally passing all the tests viz. (following are the 4 tests I am doing in application.test.js)
1) calling the getAuthenticationToken() method from authentication.js, authenticating the user with username, password, returning a AuthResponse object consisting of authentication token and refresh token, which I am catching in bundle.authData.xxx computed fields for later on usage / susequent API calls for refreshing token or polling trigger.
2) subsequently if I again call the getAuthenticationToken() method from authentication.js module, it is correctly refreshing the old authToken using the refreshToken (given to zapier in the first step). I checked it via z.console.log messages.
3) passing the “test” API call which can be reached only if user is authenticated.
4) successfully doing the trigger test locally, fetching new posts on a protected endpoint.
Even app is working on the Zapier platform (tested it via creating a Zap) to start with, polling the trigger API correctly, but same is getting 403 “Access Denied” after 15 minutes. And it is happening because Zapier by itself is not refreshing the authenticationToken. And passing the invalid JWT in the header, my back-end invalidates the Authtokens every 15 mins and expects same to be refreshed using refreshToken provided when you passed username and password.
I somehow need to call getAuthenticationToken method which is in the authentication.js module from the trigger post.js. I tried few ways but I am getting z.authData is undefined and runtime can’t read the property say refreshToken of undefined. In generic words, is it possible to call a method from authentication.js module while being in trigger post.js module. I mean it would be required in all the cases where the app have to make sure to have valid JWT in the header before polling a protected endpoint.
p.s. I am using session-auth as that is what is fitting best with my backend and can’t use o-auth2, as backend is currently not supporting o-auth2.