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