I have a Ktor client requesting from a server with Basic Auth.
When I install()
the Basic Auth as per the docs, it does not work - I get back HTTP 401.
val response1 =
HttpClient(Java.create()) {
install(Auth) {
basic {
credentials {
BasicAuthCredentials("foo@example.com", pass)
}
}
}
}
.use { it.get("https://mycompany.something.net/rest/servicedeskapi/request") }
I need to add the Auth to the request to make it work:
.use {
it.get("https://mycompany.something.net/rest/servicedeskapi/request") {
basicAuth("foo@example.com", pass)
}
}
Why is not the auth set up in the client enough? Am I doing something wrongly?