Skip to content
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

InnerHandler not available in DI container #45

Open
cbullers opened this issue Nov 9, 2022 · 2 comments
Open

InnerHandler not available in DI container #45

cbullers opened this issue Nov 9, 2022 · 2 comments

Comments

@cbullers
Copy link

cbullers commented Nov 9, 2022

When trying to use the library w/ the OAuth example project (and valid credentials), appears the OAuthHubSpotAuthenticator is trying to resolve HttpMessageHandler, while it looks like it's mocked in tests, it doesn't appear the inner handler is added to the DI container? I removed the handler from the constructor and it works fine, but I don't exactly know the implications behind that. Maybe someone could point me in the right direction? I am not entirely familiar with the pipeline. Thank you!

Unhandled exception. System.InvalidOperationException: Unable to resolve service for type 'System.Net.Http.HttpMessageHandle r' while attempting to activate 'HubSpot.Authentication.OAuthHubSpotAuthenticator'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Ty pe serviceType, CallSiteChain callSiteChain, Int32 slot) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type typ e) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain cal lSiteChain) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProvi derEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider , Type serviceType) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provi der) at Microsoft.Extensions.DependencyInjection.HttpClientBuilderExtensions.<>c__41.<AddHttpMessageHandler>b__4_1(HttpMessag eHandlerBuilder b) at Microsoft.Extensions.Http.DefaultHttpClientFactory.<>c__DisplayClass17_0.<CreateHandlerEntry>g__Configure|0(HttpMessag eHandlerBuilder b) at Microsoft.Extensions.Http.LoggingHttpMessageHandlerBuilderFilter.<>c__DisplayClass2_0.<Configure>b__0(HttpMessageHandl erBuilder builder) at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateHandlerEntry(String name) at Microsoft.Extensions.Http.DefaultHttpClientFactory.<>c__DisplayClass14_0.<.ctor>b__1() at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor) at System.Lazy1.CreateValue() at System.Lazy1.get_Value() at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateHandler(String name) at Microsoft.Extensions.Http.DefaultHttpClientFactory.CreateClient(String name) at Kralizek.Extensions.Http.HttpRestClient.CreateClient() at Kralizek.Extensions.Http.HttpRestClient.SendAsync[TContent,TResult](HttpMethod method, String path, TContent content, IQueryString query) at HubSpot.HttpHubSpotClient.HubSpot.Model.Companies.IHubSpotCompanyClient.SearchAsync(String domain, IReadOnlyList1 pro perties, Int32 limit, Nullable1 companyOffset) in C:\Users\chris\RiderProjects\hubspot-dotnet-sdk\src\HubSpot.Client\HttpHu bSpotClient.Companies.cs:line 132 at RawOAuth.Program.Main() in C:\Users\chris\RiderProjects\hubspot-dotnet-sdk\samples\hubspot-client\OAuthAuthentication\ Program.cs:line 49 at RawOAuth.Program.<Main>()

@cbullers
Copy link
Author

cbullers commented Nov 9, 2022

Looks like it may have been introduced within the latest revision, 5d421f5

@elindanielsson
Copy link
Contributor

Hi @cbullers
Did the latest release solve the problems you were having?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants