POST https://myhost.net/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type = client_credentials &
client_id = id &
client_secret = secret
getAuthToken() method accepts a payload DTO described as:
@RequiredArgsConstructor
public class AuthFormData {
private final String grant_type;
private final String client_id;
private final String client_secret;
}
When I run this code snippet:
AuthFormData authFormData = new AuthFormData("client_credentials", "id", "secret");
var authTokenResponse = client.getAuthToken(authFormData);
it unexpectedly fails with 400:
[400 Bad Request] during [POST] to [https://myhost.net/oauth/token] [PerTenantTokenClient#getAuthToken(AuthFormData)]: [{
"error" : "invalid_request",
"error_description" : "Missing parameter: grant_type"
}]
However, if I remove final from AuthFormData fields' declaration the same code succeeds.
I've tried to declare AuthFormData as Java record and it fails either (apparently due to implicit final on record members).
So my question is whether I'm facing a bug in feign client or something is wrong with my code? I use io.github.openfeign:feign-core:13.1 and Java 21
Originally asked in https://stackoverflow.com/questions/78232043/feign-client-final-fields-of-payload-object-are-not-recognized-when-executing-p
In my code I have simple Feign client:
aimed to execute the following request:
getAuthToken()
method accepts a payload DTO described as:When I run this code snippet:
it unexpectedly fails with 400:
However, if I remove
final
fromAuthFormData
fields' declaration the same code succeeds.I've tried to declare
AuthFormData
as Java record and it fails either (apparently due to implicitfinal
on record members).So my question is whether I'm facing a bug in feign client or something is wrong with my code? I use
io.github.openfeign:feign-core:13.1
and Java 21