Run actions only once per session

Problem statement

There are some actions in the tenant that call multiple APIs. Is there any way we could run these actions only once per session and not on silent auth calls or refresh token exchanges? Doing so would help to make our actions run faster.

Solution

In addition to running on a user’s login to start a session, Actions will also run on Silent Authentication requests and on Refresh Token exchanges. However, you can configure your actions to bypass these two other scenarios.

For Refresh token flows, you can simply add the following to the beginning of each action to bypass it:

  if(event.transaction.protocol === "oauth2-refresh-token"){
        return;
  }

For silent auth flows you can just change the condition to event.request.query.response_mode === 'web_message', and it should bypass the rest of the Action logic for that action as well:

 if(event.request.query.response_mode === 'web_message'){
       return;
 }
1 Like