viceroypenguin / Going.Plaid

Plaid API .NET library
https://plaid.com
MIT License
72 stars 33 forks source link

Inject a service without utilizing Blazor Hybrid #217

Closed softdevinc2 closed 6 months ago

softdevinc2 commented 7 months ago

In the PlaidQuickStartBlazor app, I see the line of code below in the Program.cs.

// Add Going.Plaid services builder.Services.AddHttpClient();

When I execute the line of code below, I can see the Http client has a property on it that is not available by default.

var createresponse = await Http.GetAsync($"link/CreateLinkToken{(IsFixingToken?"?fix=true":"")}");

It has a DefaultProxy property that does not exist on the default HttpClient. I am assuming you are adding that property in the Going.Plaid package. Ultimately, I am unable to replicate the line above in my .Net Maui app. I am not able to determine how to create a HttpClient in the manner done in the QuickStartBlazor app (i.e. @inject HttpClient Http).

I believe I need to pull the value into my application through the view model interface. Here is my view model interface.

public MainPageViewModel(IConfiguration configuration, PlaidClient client, HttpClient httpclient)

The first two parameters work well. I am able to capture the value inside the procedure with the following lines of code.

_configuration = configuration; _plaidclient = client;

I am not having any luck with the HttpClient. I have tried a variety of things in the interface with no luck. I have monkeyed with IHttpClientFactory and the HttpClient without any luck. Ultimately, I need to build a HttpClient that has the same properties and methods as the HttpClient that exists in the QuickStartBlazor app.

If you can shed any light on my issue, it would be much appreciated. Thank you in advance.

Jerry Hassett

viceroypenguin commented 7 months ago

I would encourage you to read the documentation here regarding how to use an HttpClient directly. Generally, you will not need to do so for Plaid; Going.Plaid registers an HttpClient specifically for it's use only. builder.Services.AddHttpClient() will add the IHttpClientFactory for use within your app, and so you should be able to receive the HttpClient via DI. However, you might try using builder.Services.AddTypedClient<MainPageViewModel>(), or review the commentary about named clients.

softdevinc2 commented 7 months ago

No luck.  I appreciate you trying to help. It seems the HttpClient is being configured in the background in the PlaidQuickStartBlazor solution.  Ultimately, it is made available in the C# code with the Inject statement.  Somehow I need to build out my Http client in the same manner.  The most noticeable difference between the two apps is the PlaidQuickStartBlazor app has a Http.DefaultProxy property that does not exist on the default HttpClient.  The PlaidQuickStartBlazor app has the Http.DefaultProxy set to System.Net.Http.HttpNoProxy.  Would be curious to understand how that property was added to the default HttpClient and then how the property value was set. Thanks again for trying to help!! Jerry Hassett On Wednesday, February 14, 2024 at 11:06:13 AM CST, Stuart Turner @.***> wrote:

I would encourage you to read the documentation here regarding how to use an HttpClient directly. Generally, you will not need to do so for Plaid; Going.Plaid registers an HttpClient specifically for it's use only. builder.Services.AddHttpClient() will add the IHttpClientFactory for use within your app, and so you should be able to receive the HttpClient via DI. However, you might try using builder.Services.AddTypedClient(), or review the commentary about named clients.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

softdevinc2 commented 7 months ago

Gradually finding my way.  When i talked to the Plaid Sales Rep, he mentioned a tool called Identity Verification.  Do you have any plans to incorporate the Identity Verification functionality into your toolset?  Is it just a matter of calling the correct API or APIs with the existing GoingPlaid tools? On Wednesday, February 14, 2024 at 02:13:49 PM CST, SoftDev Inc. @.***> wrote:

No luck.  I appreciate you trying to help. It seems the HttpClient is being configured in the background in the PlaidQuickStartBlazor solution.  Ultimately, it is made available in the C# code with the Inject statement.  Somehow I need to build out my Http client in the same manner.  The most noticeable difference between the two apps is the PlaidQuickStartBlazor app has a Http.DefaultProxy property that does not exist on the default HttpClient.  The PlaidQuickStartBlazor app has the Http.DefaultProxy set to System.Net.Http.HttpNoProxy.  Would be curious to understand how that property was added to the default HttpClient and then how the property value was set. Thanks again for trying to help!! Jerry Hassett On Wednesday, February 14, 2024 at 11:06:13 AM CST, Stuart Turner @.***> wrote:

I would encourage you to read the documentation here regarding how to use an HttpClient directly. Generally, you will not need to do so for Plaid; Going.Plaid registers an HttpClient specifically for it's use only. builder.Services.AddHttpClient() will add the IHttpClientFactory for use within your app, and so you should be able to receive the HttpClient via DI. However, you might try using builder.Services.AddTypedClient(), or review the commentary about named clients.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

viceroypenguin commented 7 months ago

I'm not familiar with "Identify Verification", specifically, but if it's in the Plaid API, then we support it, at least nominally. I'm guessing the apis you're looking for would be found here: https://github.com/viceroypenguin/Going.Plaid/tree/master/src/Plaid/IdentityVerification

softdevinc2 commented 6 months ago

Thank you!! On Monday, February 19, 2024 at 05:10:41 PM GMT-6, Stuart Turner @.***> wrote:

I'm not familiar with "Identify Verification", specifically, but if it's in the Plaid API, then we support it, at least nominally. I'm guessing the apis you're looking for would be found here: https://github.com/viceroypenguin/Going.Plaid/tree/master/src/Plaid/IdentityVerification

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>