I am trying to connect my Excel Add In to Azure SignalR. I already connected a WPF app - but apparently AspNet Core is not supported in Office Add Ins (getting a DisposeAsync not implemented exception) so i am using the assembly Microsoft.AspNet.SignalR.Client instead.
My code so far:
var query = new Dictionary<string, string>();
query.Add("version", "1.0");
query.Add("Authorization", GenerateAccessToken());
query.Add("hub", _hubName);
connection = new HubConnection(_endpoint, query);
connection.Headers.Add("Authorization", "Bearer " + GenerateAccessToken());
hubProxy = connection.CreateHubProxy(_hubName);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
connection.Start().Wait();
Executing "connection.Start().Wait()" gives my the following error:
HttpClientException: StatusCode: 403, ReasonPhrase: 'Forbidden', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Connection: keep-alive
Strict-Transport-Security: max-age=15724800; includeSubDomains
Date: Sun, 25 Jun 2023 18:47:53 GMT
Content-Length: 146
Content-Type: text/html
}
The _endpoint is "https://(me).service.signalr.net" replacing (me) with the correct name.
The odd thing is when looking in fiddler i get code 200 with the following call from the WPF app:
POST https://<me>.service.signalr.net/client/negotiate?hub=default&negotiateVersion=1
When i run the code above it gives me:
GET https://<me>.service.signalr.net/signalr/negotiate?clientProtocol=2.1&connectionData=%5B%7B%22Name%22:%22default%22%7D%5D&version=1.0&Authorization=(access_token.....)
I dont know how to change the endpoint (from signalr to client) or the method. I cannot put parameters on the endpoint without it throwing an exception. If i fill out the query list i seems like a wrong endpoint.
I cannot find any good resources for connecting (including the authorization) to Azure SignalR without AspNet Core.
Any help would be greatly appreciated!