viceroypenguin / Going.Plaid

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

Access Token Sent in Request #191

Closed matt-lethargic closed 9 months ago

matt-lethargic commented 10 months ago

While sending post requests to the sandbox I'm getting the below error:

the following fields are not recognized by this endpoint: access_token

It seems that the access_token, secret, client_id and maybe some other fields in RequestBase.cs are being sent in the request body. I'm not sure if this is because I've configured something wrong in my code or if there is a genuine bug in the nuget package.

Here is an example of the code I'm trying

Program.cs

builder.Services.Configure<PlaidCredentials>(builder.Configuration.GetSection(PlaidOptions.SectionKey));
builder.Services.Configure<PlaidOptions>(builder.Configuration.GetSection(PlaidOptions.SectionKey));
builder.Services.AddSingleton<PlaidClient>();

PaymentController.cs

 PaymentInitiationRecipientCreateRequest request = new PaymentInitiationRecipientCreateRequest
                {
                    Name = "Bob",
                    Iban = "AB1234566",
                    Bacs = new RecipientBACS
                    {
                        Account = "123455666",
                        SortCode = "123456"
                    },
                    Address = new PaymentInitiationAddress
                    {
                        Street = new string[] { "5 Main Street" },
                        City = "London",
                        PostalCode = "NE1234D",
                        Country = "United Kingdom"
                    }
                };

 var response = await _client.PaymentInitiationRecipientCreateAsync(request);

Any help on this would be great

viceroypenguin commented 9 months ago

Please give v6.10.1 a try. It should resolve this specific issue. I do not currently have any automation around looking for endpoints that don't need the access_token, so they are manually updated to exclude the token on certain endpoints. I have done it for this one; please re-open or create a new issue if you find any other endpoints.

sebastienlabine commented 3 months ago

ExchangePublicTokenAsync is one of them. getting the error

viceroypenguin commented 3 months ago

ExchangePublicTokenAsync is one of them. getting the error

@sebastienlabine If you're referring to ItemExchangePublicTokenAsync(), then this is already handled via the request overrides here: https://github.com/viceroypenguin/Going.Plaid/blob/master/src/Plaid/RequestClassOverrides.cs#L29. If you can share your error information in a new ticket, I might be able to assist you.

sebastienlabine commented 3 months ago

@viceroypenguin That's what I saw too, but I had to explicitly set it to null in order to be unserialized.

Plaid error returns

the following fields are not recognized by this endpoint: access_token

From what I can see, you set accessToken at the creation of the PlaidClient, which seems to be the cause of my error: https://github.com/viceroypenguin/Going.Plaid/blob/fdaa42fe096e85265e3e921e16ccc0e2a94a8d2e/src/Plaid/PlaidClient.cs#L77

viceroypenguin commented 3 months ago

@sebastienlabine Please open a new ticket and share some of the code you are using.