use jwt connect evevt grid Token containes invalid audience

develop ainfinit 0 Reputation points
2025-12-23T06:35:24.8266667+00:00

use jwt connect event grid failed

log "Token containes invalid audience"

event grid setting

"topicSpacesConfiguration": {
                    "state": "Enabled",
                    "clientAuthentication": {
                        "customJwtAuthentication": {
                            "tokenIssuer": "mqtt-issuer",
                            "issuerCertificates": [
                                {
                                    "certificateUrl": "https://xx.vault.azure.net/certificates/jwt-issuer/x",
                                    "identity": {
                                        "type": "SystemAssigned"
                                    }
                                }
                            ]
                        }
                    },
                    "maximumSessionExpiryInHours": 1,
                    "maximumClientSessionsPerAuthenticationName": 1
                }


Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
{count} votes

1 answer

Sort by: Most helpful
  1. Q&A Assist
    2025-12-23T06:35:32.6066667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    The error message "Token contains invalid audience" indicates that the aud claim in your JWT token does not match the expected audience for your Azure Event Grid namespace. To resolve this issue, ensure that the aud claim in your JWT is set correctly. It should be in the format of [namespace][region]-1.ts.eventgrid.azure.net/, where [namespace] is your Event Grid namespace and [region] is the Azure region where your namespace is hosted.

    Additionally, verify that your Event Grid configuration is set up correctly for custom JWT authentication, including the issuer and the certificate settings. If the aud claim does not match the expected audience, the authentication will fail, resulting in the error you are seeing.

    Make sure to check the following:

    1. The aud claim in the JWT matches the expected format.
    2. The issuer (iss) in the JWT matches the tokenIssuer specified in your Event Grid settings.
    3. The JWT is not expired and is correctly signed with the issuer's certificate.

    If these settings are correct and you are still facing issues, consider refreshing your JWT token and trying again.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.