This repository provide a sophisticated http client wrapper.
- Create jar resource using
./gradlew clean build - Copy
/build/libs/*.jarinto your project - Use the http client classes
You can pull the latest binaries from the central Maven repositories:
with Gradle
implementation("de.alexanderwolz:http-client:1.4.4")with Maven
<dependency>
<groupId>de.alexanderwolz</groupId>
<artifactId>http-client</artifactId>
<version>1.4.4</version>
</dependency>val formPayload = Payload.create(
BasicContentTypes.FORM_URL_ENCODED,
Form(
"grant_type" to "client_credentials",
"client_id" to "XYZ12345",
"client_secret" to "9876543ABC",
"scope" to "oidc"
)
)
val client = HttpClient.Builder()
.method(HttpMethod.POST)
.endpoint("https://sso.example.com/token")
.accept(BasicContentTypes.OAUTH_TOKEN)
.body(formPayload)
.build()
val response = client.execute()
if (response.isOK && response.body.type == BasicContentTypes.OAUTH_TOKEN) {
val accessToken = response.body.element as OAuthTokenResponse
} else{
throw Exception("Received error ${response.code}")
}Made with ❤️ in Bavaria
© 2025, Alexander Wolz