Signalr.hubconnectionBuilder ()

var connection = new signalR.HubConnectionBuilder()
    //.withUrl("https://localhost:44335/chatHub").build();
    //.withUrl("https://localhost:44335/chatHub", (opts) => {
    //    opts.Headers.Add("Authorization", new AuthenticationHeaderValue(
    //        "Basic", Convert.ToBase64String(
    //            Encoding.Default.GetBytes(
    //                "Username" + ":" + "Password"
    //            ))).ToString());
    //})
    //.build();
    .withUrl("https://localhost:44335/chatHub", { accessTokenFactory: () => "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTUzNzI1NTAsImlzcyI6ImFhYSIsImF1ZCI6ImJiYiJ9.nGMb7sb72IWj3BPRn-OKJx-0oeTW_N7cp1ZGaPFBuNY" }).build();
    //.withUrl("https://localhost:44335/chatHub", {
    //    // "Foo: Bar" will not be sent with WebSockets or Server-Sent Events requests
    //    headers: { "Authorization": "Bar" },
    //    transport: signalR.HttpTransportType.LongPolling
    //}).build();
Thitipong Hangwongpaibool