org.openapitools.client.auth.HttpBasicAuth.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-client-petstore-multiplatform
Show all versions of kotlin-client-petstore-multiplatform
A demo for deployment to the Central Repository. A kotlin client library for OpenAPI Petstore by org.openapitools
The newest version!
package org.openapitools.client.auth
import io.ktor.util.InternalAPI
import io.ktor.util.encodeBase64
class HttpBasicAuth : Authentication {
var username: String? = null
var password: String? = null
@InternalAPI
override fun apply(query: MutableMap>, headers: MutableMap) {
if (username == null && password == null) return
val str = (username ?: "") + ":" + (password ?: "")
val auth = str.encodeBase64()
headers["Authorization"] = "Basic $auth"
}
}