Caching Does Not Work in the M2M Credentials-Exchange Trigger

Overview

This article explains a potential cause of a failure to Caching an Access Token in the credentials-exchange trigger. A forever loop appears, and the cache is never populated.

Applies To

  • Access Tokens
  • Cache

Cause

The credentials-exchange trigger should not be used to cache an Access Token.

Solution

  • Generally, an Access Token is cached, and a new request for a token is made if the cache does not return the cached entry.
  • This setup should not be used in the credentials-exchange trigger because when the credentials-exchange trigger executes, the Access Token would not have been issued
  • This means there is nothing to cache, and a looping scenario will be experienced as the credentials exchange trigger is executed again due to the request for a new token.

The cache is designed to cache the M2M Access Token, but it should be cached in the post_login or whichever other trigger is relevant, NOT in the credentials-exchange Action.