title: SignalR connection with accessTokenFactory on JS client doesn't connect with connectionId and UserIdentifier but .Net client is fine
body: <p>In my SignalR Authentication prototype, the JS client doesn't have a Context.UserIdentifier and the connectionId will be 0 when connecting to the SignalR hub on the JS client side. It works fine with the .NET client.</p>
  
  <p>Wondering if constructing the connection is wrong?
  This is my connection: </p>
  
  <pre><code>state.connection = new signalR.HubConnectionBuilder()
                  .withUrl("/chatHub", {
                      accessTokenFactory: async () =&gt; {
                          axios.post('https://localhost:44384/api/account/token', { email: email, password: password })
                              .then(async (response) =&gt; {
                                  if (typeof response === 'undefined') {
                                      return;
                                  }
                                  else {
                                      console.log(response.data);
                                      console.log(state.connection.id);
                                      return response.data;
                                  }
                              })
                              .catch((error) =&gt; {
                                  console.log(error);
                              });
                      }
                  })
                  .build();   
  </code></pre>
  
  <p>The WPF client connects with the token just fine with this code: </p>
  
  <pre><code>_connection = new HubConnectionBuilder()
              .WithUrl("https://localhost:44384/ChatHub", options =&gt;
              {
                  options.AccessTokenProvider = async () =&gt;
                  {
                      var tokenUserCommand = new TokenUserCommand
                      {
                          Email = emailTextBox.Text,
                          Password = passwordBox.Password
                      };
  
                      var token = await RestService.PostAsync&lt;string&gt;("account/token", tokenUserCommand);
                      return token;
                  };
  
              })
              .Build();
  </code></pre>
  
  <p>Where I found <a href="https://docs.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-2.2" rel="nofollow noreferrer">SignalR Authentication configuration</a>
  and <a href="https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-2.2&amp;tabs=dotnet#configure-bearer-authentication" rel="nofollow noreferrer">SignalR Bearer Authentication</a></p>
  
  <p>Here is the <a href="https://github.com/DanielRBowen/AuthnAuthzSignalR" rel="nofollow noreferrer">source for my prototype project</a></p>