You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/10/19 07:26:23 UTC

[GitHub] [pulsar-dotpulsar] VisualBean commented on issue #92: Client usage

VisualBean commented on issue #92:
URL: https://github.com/apache/pulsar-dotpulsar/issues/92#issuecomment-946437489


   Yes, the other clients has this support through a plugin called `AuthenticationOauth2`. However, I would be fine with simply having a delegate I could use, like the Microsoft Graph Client for instance;
   ```csharp
    var pca = PublicClientApplicationBuilder
       .Create(clientId)
       .WithTenantId(tenantId)
       .Build();
   
   var authProvider = new DelegateAuthenticationProvider(async (requestMessage) =>
   {
       var result = await pca.AcquireTokenByUsernamePassword(defaultGraphScopes, username, password).ExecuteAsync();
       requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", result.AccessToken);
   });
   
   new GraphServiceClient(authProvider);              
   ```
   where you basically just pass it the logic for getting a new token. - I would be perfectly fine with managing the caching myself as well (which is also why im thinking to just wrap the client creation in yet another factory)
   
   I guess the connection pool is referenced in the PulsarClientBuilder, right? So I guess as long as we keep this instance around, it is fine.
   
   My worry is creating too many clients, since we have to create a new one when our tokens expire (every 30 minutes or so). 30 minutes is more than enough for resetting the socket, so we dont get port exhaustion, but it made me ask anyway.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org