Event Hub with authentication not working

I’ve got an Event Hub defined, with authentication enabled and the Administrator role being selected for it.

When I set my agent to connect and supply an app token for an identity that’s assigned to the Administrator role, I get an error in the agent log stating “401 (Unauthorized)”. If I disable authentication on the Event Hub and take the token out of the agent.json file, I can connect without an issue. I’ve tried the token in the enhanced token format as well as a Base64 encoded version of the identity and its password, neither of which worked. Any suggestions?

For reference, here’s the log entry:

2025-02-18 12:52:19.688 -05:00 [INF] Starting connections (1).
2025-02-18 12:52:19.791 -05:00 [INF] Starting connection to https://<redacted> at hub <redacted>.
2025-02-18 12:52:19.862 -05:00 [WRN] Unsuccessful HTTP response "Unauthorized" return from POST '"https://<redacted>/autheventhub/negotiate?group=<redacted>&negotiateVersion=1"'.
2025-02-18 12:52:19.867 -05:00 [ERR] Failed to start connection. Error getting negotiation response from '"https://<redacted>/autheventhub?group=<redacted>"'.
System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync(Uri url, HttpClient httpClient, ILogger logger, CancellationToken cancellationToken)
2025-02-18 12:52:19.875 -05:00 [ERR] Error connecting to server https://<redacted> at hub <redacted>: Response status code does not indicate success: 401 (Unauthorized).
Product: PowerShell Universal
Version: 5.3.1

Anyone?

1 Like

I don’t have anything to help but I’ve used it with 5.3.0, 5.3.1, and 5.3.2 and token auth has been working for us using both administrator and another app specific token. If it helps we are using a SQL back end

1 Like

It isn’t working with 5.3.1 and SQLite over here. I haven’t tried since upgrading to 5.3.2, but I don’t see anything in the release notes about fixes for authentication to Event Hubs so I don’t expect anything to have changed.

Edit: I just tried with 5.3.2 and it works with the same settings and token that did NOT work in 5.3.1. So, something definitely did change with regard to authentication of Event Hubs. I can’t speak to why it worked for you with 5.3.1 (and lower) but not for me.

5.3.2 appears to have fixed another event hub issue I was having as well. It wasn’t auth related but it is still working at least.

1 Like