Skip to content

Commit

Permalink
fix: log authentication requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Dwairi committed Dec 1, 2024
1 parent 7362ce2 commit 95ddb46
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ import com.expediagroup.sdk.core.http.MediaType
import com.expediagroup.sdk.core.http.Request
import com.expediagroup.sdk.core.http.RequestBody
import com.expediagroup.sdk.core.http.Response
import com.expediagroup.sdk.core.logging.common.RequestLogger
import com.expediagroup.sdk.core.logging.common.ResponseLogger
import com.expediagroup.sdk.core.model.exception.client.ExpediaGroupResponseParsingException
import com.expediagroup.sdk.core.model.exception.service.ExpediaGroupAuthException
import com.expediagroup.sdk.core.model.exception.service.ExpediaGroupNetworkException
import org.slf4j.LoggerFactory

/**
* Manages bearer token authentication for HTTP requests.
Expand All @@ -43,6 +46,7 @@ class BearerAuthenticationManager(
private val transport: Transport,
private val credentials: Credentials
) : AuthenticationManager {
private val logger = LoggerFactory.getLogger(BearerAuthenticationInterceptor::class.simpleName)

@Volatile
private var bearerTokenStorage = BearerTokenStorage.empty
Expand All @@ -60,9 +64,13 @@ class BearerAuthenticationManager(
override fun authenticate() {
clearAuthentication()
.let {
buildAuthenticationRequest()
buildAuthenticationRequest().also {
RequestLogger.log(logger, it)
}
}.let {
executeAuthenticationRequest(it)
executeAuthenticationRequest(it).also {
ResponseLogger.log(logger, it)
}
}.let {
TokenResponse.parse(it)
}.also {
Expand Down

0 comments on commit 95ddb46

Please sign in to comment.