Last Updated: Jul 9, 2024
Overview
Login via a newly configured SAML connection fails and displays the error:
Audience is invalid
According to the SAML troubleshooting guidance in the Auth0 documentation (refer to Troubleshoot SAML Errors ):
- “This error occurs if the value of the audience element from the identity provider’s SAML response does not match the value expected by Auth0. Auth0 expects the value to be the Entity ID for the connection”.
It then says to go to the Common Settings and view the Entity ID. This article describes the purpose of the Entity ID and where it can be found in the SAML connection settings.
Troubleshooting
- Capture the failed login flow in a HAR file for later analysis. For further information, refer to Generate and Analyze HAR Files.
- Review the HAR file and look for the Audience value in the SAML response: use the Auth0 SAML tool for this purpose.
- It must match the configured value of the Entity ID within the SAML connection.
- The Entity ID should be in this format:
urn:auth0:TENANT:CONNECTION
Cause
The error message may arise when:
- the Identity Provider (IdP) fails to send the correct
audience
value in the SAML response. - the Entity ID is missing or incorrectly configured in the SAML connection.
Solution
Role Played by Entity ID
Both the Service Provider (SP) and the Identity Provider ( IdP) are considered to be entities in a SAML transaction. Each of these is assigned a unique Entity ID, which plays several roles:
- Uniqueness: the ID ensures that only the desired parties are involved in a SAML transaction.
- Routing: the ID ensures that messages are routed to the correct entity ( SP, IdP ).
- Metadata: contains information about the endpoints, keys, and other settings necessary for the secure exchange of SAML messages. Here, the Entity ID is used to associate the SP or IdP with its corresponding set of metadata.
- Configuration: the ID performs an important role in configuring the SP and IdP, providing a unique identifier for each communicating entity.
The Entity ID is frequently expressed in an ‘urn**’** format. In an Auth0 context, the common structure for this is as defined as follows:
For public cloud tenants:
urn:auth0:YOUR_TENANT:YOUR_CONNECTION_NAME
For private cloud tenants:
urn:config:YOUR_TENANT:YOUR_CONNECTION_NAME
How to Find the Entity ID
- Login to the Auth0 dashboard as a tenant member ( Administrator ).
- If necessary, switch to the required tenant. For further information, refer to Manage account settings.
- Login to the Documentation website with the Auth0 account details.
- Navigate Authentication > Enterprise Connections > SAML.
- On the top horizontal menu, Click Setup.
- Respond to the prompt “If you are an administrator of this domain” > click Continue.
- Land on the documentation page SAML Identity Provider Configuration Settings.
- Scroll down to the section Entity ID.
- The Entity ID of the Service Provider (SP) will be displayed and will take this form:
urn:auth0:tenant-name:{yourConnectionName}
orurn:config:tenant-name:{yourConnectionName}
depending on the environment type.
NOTE: If Audience is Invalid error is shown even when confirming that the Entity ID matches the Audience, set a custom entity ID on both the IdP and the connection to see if the issue is resolved.