I was trying to configure a Spring Boot OAuth2RestTemplate to issue an access token for an OAuth2 Resource Server. The Resource Server only accepts the credentials in the Request Body.
Something like this:
grant_type: "client_credentials"
scope: ""
client_id: "client"
client_secret: "superdupersecret"
In Postman I can archive this by selecting "Send client credentials in body" in the "Get new access token" dialog.
However, I need to get this token in my Spring Boot application. I debugged the OAuth2RestTemplate (and the classes used by the template) but couldn't find a way to configure it to send the credentials as request body.
Am I completely on the wrong track here or just missing something?
Currently I configure the template like this:
private fun resourceDetails(): BaseOAuth2ProtectedResourceDetails? {
val resourceDetails: BaseOAuth2ProtectedResourceDetails = ClientCredentialsResourceDetails()
resourceDetails.id = clientId
resourceDetails.clientId = clientId
resourceDetails.clientSecret = clientSecret
resourceDetails.accessTokenUri = accessTokenUri
//resourceDetails.clientAuthenticationScheme = AuthenticationScheme.header
return resourceDetails
}
I found the clientAuthenticationScheme parameter but only query, form and header are supported