Hello. I’m struggling wtih Ktor client auth. I alw...
# ktor
p
Hello. I’m struggling wtih Ktor client auth. I always receive a 401 error with the following code:
Copy code
val client = HttpClient(Apache) {
    install(Auth) {
        followRedirects = true
        basic {
            sendWithoutRequest = true
            username = login
            password = pwd
        }
    }
}
runCatching {
    client.get<HttpResponse>(AUTH_URL)
}.onSuccess {
    client.close()
    print(it.headers)
    return it.status == HttpStatusCode.OK
}.onFailure {
    it.printStackTrace()
    client.close()
    throw it
}