Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: injectable http client #112

Closed
wants to merge 17 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: log authentication requests
Mohammad-Dwairi committed Dec 1, 2024
commit 95ddb46db6f38e6a7669f5c938f6176414620df3
Original file line number Diff line number Diff line change
@@ -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.
@@ -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
@@ -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 {