-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AccessTokenHandler does not support sync methods #28
Comments
It looks like I'll transfer this issue to our FOSS repository (the home for Duende.AccessTokenManagement) for handling. |
Thank you for bringing this to our attention. I understand that the open telemetry library invokes the synchronous send operation, which is currently not supported. . Unfortunately, the only way we could implement a synchronous Send() is by doing .GetAwaiter().GetResult(), which is absolutely not a recommended practice and not something we're considering implementing. However, we should fail fast when the synchronous Send() method is invoked. So this is a change that we'll introduce in the near future. In the open telemetry library there's a PR and a big discussion associated with it to make this functionality async (open-telemetry/opentelemetry-dotnet#5838). Now this PR isn't merged yet and no ETA on this, Should you accept the issues and risks associated with calling .GetAwaiter().GetResult(), you can always create your own subclass of the Handler that doesn't throw like this: public class SynchronousOpenIdConnectClientAccessTokenHandler : OpenIdConnectClientAccessTokenHandler
{
public SynchronousOpenIdConnectClientAccessTokenHandler(IDPoPProofService dPoPProofService, IDPoPNonceStore dPoPNonceStore, IHttpContextAccessor httpContextAccessor, ILogger<OpenIdConnectClientAccessTokenHandler> logger, UserTokenRequestParameters? parameters = null) : base(dPoPProofService, dPoPNonceStore, httpContextAccessor, logger, parameters)
{
}
protected override HttpResponseMessage Send(HttpRequestMessage request, CancellationToken cancellationToken)
{
// Please note that this code (depending on where it's invoked) is subject to deadlocks and thread pool starvation
return base.SendAsync(request, cancellationToken).GetAwaiter().GetResult();
}
} |
Which version of Duende.AccessTokenManagement are you using?
3.0.0
Which version of .NET are you using?
6
Describe the bug
I'm try to use the OpenTelemetryClient from dotnet together with the AccessTokenManagement.
Setup like this:
Later on in my implementation I pass the IHttpClientFactory in my class:
To Reproduce
See the source above. Where the httpClient is created I'm doing a send which does not request tokens. I saw that in the logs.
When I call SendAsync, then the lib is requesting a token.
Expected behavior
Also Send method will request a token.
Additional context
src/Duende.AccessTokenManagement/AccessTokenHandler.cs
Does not override the Send method, but SendAync only.
The text was updated successfully, but these errors were encountered: