org.openapitools.client.auth.HttpBearerAuth.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
class HttpBearerAuth(private val scheme: String?) : Authentication {
var bearerToken: String? = null
override fun apply(query: MutableMap>, headers: MutableMap) {
val token: String = bearerToken ?: return
headers["Authorization"] = (if (scheme != null) upperCaseBearer(scheme)!! + " " else "") + token
}
private fun upperCaseBearer(scheme: String): String? {
return if ("bearer".equals(scheme, ignoreCase = true)) "Bearer" else scheme
}
}