How to Run a Schedule(Timer) Script at the Client Session – For Token Refresh in Perspective

Hello everyone,

I'm working on a Perspective application using Ignition 8.3. My requirement is to periodically refresh the authentication token (Through AWS Cognito) for each user. This task needs to be executed on a fixed time interval (e.g., every 5 minutes) and must run independently within the context of each active Perspective client session.

This ensures that the unique token for that user remains valid without relying on a global Gateway script.

My questions is: What is the recommended method and where for running a script periodically that is scoped specifically to the client session?

Thank you in advance for your guidance!

Are you sure you need different tokens for each client?

1 Like

All scripts in perspective run on the gateway, so all requests will come from the gateway, not the session. You could attach context to the requests and have individual tokens, but you're better off just using one token for the gateway and refreshing it only for the gateway.

1 Like

Yes. In our case, each Perspective session represents an individual user logging in with their own Cognito user account.

That’s a good point. And yes, I understand that all Perspective scripts actually execute on the Gateway.

In our case though, each user logs in through Cognito with their own credentials, and the access token is used to identify and authorize that individual when calling our backend APIs.

So we do need to maintain per-session tokens,and it just needs to store and update the tokens separately for each Perspective session.

Store the token in the session props, pass it to the gateway on demand with message handlers.

1 Like

And make sure to set the access of that prop to private.