Support for gRPC clients in Duende.AccessTokenManagement (similar to AddUserAccessTokenHttpClient) #275
-
|
Hi, I was wondering if there is any interest or ongoing work around supporting gRPC in a similar way that AddUserAccessTokenHttpClient supports HTTP clients. Currently, we can easily configure HttpClient instances to automatically attach user or client access tokens using the extension methods provided. However, there doesn’t seem to be an equivalent for Grpc.Net.Client. I imagine the desired experience would be something like services.AddUserAccessTokenGrpcClient<IMyGrpcService>( client =>
{
client.Address = new Uri("https://localhost:5001");
});Where the token is automatically retrieved and attached to gRPC calls via headers . Has this been considered before? I’d love to hear if: Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
If you're using a strongly typed gRPC client, you can leverage the fact that it uses an builder.Services.AddOpenIdConnectAccessTokenManagement();
builder.Services.AddGrpcClient<Greeter.GreeterClient>(o =>
{
o.Address = new Uri("https://localhost:5001");
})
.AddUserAccessTokenHandler();
// or .AddClientAccessTokenHandler(); when using client credentialsIs this what you were looking for? There is indeed no current alternative for configuring gRPC clients like you suggested. |
Beta Was this translation helpful? Give feedback.
If you're using a strongly typed gRPC client, you can leverage the fact that it uses an
HttpClientinternally:Is this what you were looking for? There is indeed no current alternative for configuring gRPC clients like you suggested.