pulsar-client-dotnet icon indicating copy to clipboard operation
pulsar-client-dotnet copied to clipboard

Async token supplier / non-file-based oauth2

Open aeons opened this issue 1 year ago • 3 comments

It would be great if we could either

  1. supply an async token supplier, or
  2. give the oauth2 credentials as configuration instead of a file

aeons avatar Mar 01 '24 12:03 aeons

@aeons Authentication is an abstract class, so you can write your own implementation of it using configuration. As for async version (I suppose you are talking about making GetAuthData method async) - it could be a good idea, but it is initially sync in java, so Pulsar.Client just followed it to simplify understanding and now it would be a breaking change

Lanayx avatar Mar 01 '24 18:03 Lanayx

I get that I can write my own implementation, but since there already is one included, it would be nice to just be able to do

.Authentication(AuthenticationFactoryOAuth2.ClientCredentials(issuerUrl, audience, clientId, clientSecret))

For the sync vs async, getting an oauth2 token will always be async, so having the method be sync will always introduce blocking, but I do get the reasoning to follow the reference implementation.

aeons avatar Mar 04 '24 12:03 aeons

I was disappointed to find I can't supply a base64 encoded URI in the form: data:application/json;base64,<base64-encoded value>

It looks like the AuthenticationFactoryOAuth2.ClientCredentials is trying to append the URI to the current working directory to find a file, and fails.

chriscameron-vertexinc avatar May 14 '24 15:05 chriscameron-vertexinc

@chriscameron-vertexinc You are welcome to send a PR with an improvement. Right now only the LocalPath of URI is used , but I think we can extend it with base64 encoded value support.

Lanayx avatar May 14 '24 20:05 Lanayx

@Lanayx I've opened a completely untested PR here https://github.com/fsprojects/pulsar-client-dotnet/pull/263

I'll try it out tomorrow, but in the meantime I'd appreciate any feedback. I haven't written any F# before!

chriscameron-vertexinc avatar May 15 '24 02:05 chriscameron-vertexinc

@chriscameron-vertexinc Thanks, good job for the first time F#! I've added some style recommendations and will be ready to merge once you confirm it works

Lanayx avatar May 15 '24 03:05 Lanayx

Published https://www.nuget.org/packages/Pulsar.Client/3.5.0 with the improvement

Lanayx avatar May 15 '24 23:05 Lanayx

Closing as completed

Lanayx avatar May 18 '24 23:05 Lanayx