Auth0 Custom Token Exchange Error When Using setUserByConnection With Unsupported Social Connections
Last Updated:
Overview
When using the custom-token-exchange Action trigger in Auth0, the api.authentication.setUserByConnection method fails for certain social connections. To resolve this, use the setUserById method instead. This issue occurs when attempting to use setUserByConnection with an unsupported social connection, regardless of whether the creationBehavior value is set to none or create_if_not_exists.
Auth0 generates the following error:
The connection strategy 'connection_name' is not supported for this operation.
{
"type": "fecte",
"description": "The connection strategy 'connection_name' is not supported for this operation."
}Applies To
- Auth0
- Actions
- Custom Token Exchange
- Social Connections
Cause
Auth0 restricts the api.authentication.setUserByConnection method to a specific list of allowed federated connection strategies. If the allowed list omits the specified social connection, the operation fails and generates an error.
Solution
How is the Auth0 Custom Token Exchange Error resolved?
To resolve this error, replace the api.authentication.setUserByConnection method with the setUserById method in the Action script. The setUserById method functions correctly for all social connections, including those absent from the allowed federated connection strategies list.