Expired tokens might lead to confusion of your Application users, as Business Object and Connector calls will fail and throw errors in your Application, if not handled properly.
This article shows how to prevent this and to handle expired tokens.
Prerequisites
First you should activate user notification before token expires to make user aware, that the session is ending soon. (Read more in Documentation, chapter ‘Notification settings’)
But what if the user ignores the notification and token gets expired anyways. You can simplify the handling of expired tokens with our Marketplace Library ‘Token Lifetime Validator‘. Get it from marketplace and import it to your instance before starting.
Features
As soon as the Library is added to an Application, it automatically checks token expiry.
When a token expires, user is logged out. In addition a custom event is published which can be subscribed in Process Designer to add custom handling of expired tokens (e.g. navigate to login page, reset of variables, etc.).
If the event is not configured in Data Workbench, a default dialog is shown to the user. On confirming the dialog the Application is reloaded.
Implementation
Step 1 – Add the library to your instance
Navigate to Transports and go to the tab Import. Click on the area named “Choose file” or the button “Browse” and select the downloaded import file.
If you need more details on how to import a Transport see our Documentation.
Step 2 – Add the library to your Application
Open the Application you add want to the library to. Click on the tab “Other” and choose Libraries.
Now, press the “+”-icon in the top far right corner and add the library to this specific application. Select the imported library and add it by clicking on OK.
You have implemented everything necessary and can start to design your custom handling of expired tokens.
Step 3 (Optional) – Add custom handling of expired tokens
Per default, on token expiry users gets displayed a dialog. After confirming the dialog, the Application is reloaded.
To add custom handling of expired tokens instead, just navigate to the Data Workbench inside your application, create a new custom event and name it “tokenExpired”.
Now subscribe this event in the Process Designer and connect it to your UI Actions, Navigations or whatever your process requires.
Step 4 – Deploy Application
Finally deploy your Application and the handling of expired tokens is active.
Have fun implementing your custom handling of expired tokens!