Ktor client supports authentication out of the box as a standard pluggable feature:
io.ktor.client.features.auth.Auth
        
        
            in the artifact io.ktor:ktor-client-auth:$ktor_version.
        
        
        
        
    dependencies {
    compile "io.ktor:ktor-client-auth:$ktor_version"
}
dependencies {
    compile("io.ktor:ktor-client-auth:$ktor_version")
}
<project>
    ...
    <dependencies>
        <dependency>
            <groupId>io.ktor</groupId>
            <artifactId>ktor-client-auth</artifactId>
            <version>${ktor.version}</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
</project>
val client = HttpClient() {
    install(Auth) {
        // providers config
        ...
    }
}
This provider sends an Authorization: Basic with the specified credentials:
val client = HttpClient() {
    install(Auth) {
        basic {
            username = "username"
            password = "password"
        }
    }
}
This feature implements the IETF’s RFC 7617.
This provider sends an Authorization: Digest with the specified credentials:
val client = HttpClient() {
    install(Auth) {
        digest {
            username = "username"
            password = "password"
            realm = "custom"
        }
    }
}
This feature implements the IETF’s RFC 2617.