Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Cómo pasar valor en lugar de token de acceso en SignalR HubConnectionBuilder

Como se menciona en el documento de MS , puede autorizar su SignalR con un token de acceso como este:

 let connection = new signalR.HubConnectionBuilder() .withUrl("/chathub", { accessTokenFactory: () => { // Get and return the access token. // This function can return a JavaScript Promise if asynchronous // logic is required to retrieve the access token. } }) .build();

y puede usar en su código de fondo (con IUserIdProvider) como este

 public class EmailBasedUserIdProvider : IUserIdProvider { public virtual string GetUserId(HubConnectionContext connection) { return connection.User?.FindFirst(ClaimTypes.Email)?.Value!; } }

No tengo un token adecuado para pasar a accessTokenFactory, pero tengo UserId en mi cliente y quiero usar este userIs con el método GetUserId, para poder distinguir a quién pertenece el chat por UserId en lugar de token completo. ¿Es posible pasar otro valor (o solo un reclamo) a HubConnectionBuilder? Como por ejemplo:

 let connection = new signalR.HubConnectionBuilder() .withUrl("/chathub", { accessTokenFactory: () => { // Pass your value or just a custom claim so it could be retrive on server side } }) .build();
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!