From 1d5fcc57c8c9681e03e0009c7a769b4e7519f06d Mon Sep 17 00:00:00 2001 From: Richard Borge Date: Wed, 6 Dec 2023 14:40:39 +0100 Subject: [PATCH] Logger token-feil Co-authored-by: Robin Tordly Co-authored-by: Vetle Hollund --- .../main/no/nav/aap/ktor/client/AzureAdTokenProvider.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ktor-auth-azuread/main/no/nav/aap/ktor/client/AzureAdTokenProvider.kt b/ktor-auth-azuread/main/no/nav/aap/ktor/client/AzureAdTokenProvider.kt index 3c445525..fff43bc0 100644 --- a/ktor-auth-azuread/main/no/nav/aap/ktor/client/AzureAdTokenProvider.kt +++ b/ktor-auth-azuread/main/no/nav/aap/ktor/client/AzureAdTokenProvider.kt @@ -7,9 +7,13 @@ import io.ktor.client.call.* import io.ktor.client.engine.cio.* import io.ktor.client.plugins.contentnegotiation.* import io.ktor.client.request.* +import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.serialization.jackson.* import no.nav.aap.cache.Cache +import org.slf4j.LoggerFactory + +private val secureLog = LoggerFactory.getLogger("secureLog") class AzureAdTokenProvider( private val config: AzureConfig, @@ -36,6 +40,10 @@ class AzureAdTokenProvider( accept(ContentType.Application.Json) contentType(ContentType.Application.FormUrlEncoded) setBody(body()) + }.also { + if(!it.status.isSuccess()) { + secureLog.warn("Feilet token-kall {}: {}", it.status.value, it.bodyAsText()) + } }.body().also { fetchedToken -> fetchedToken.addToCache(tokenCache, cacheKey) }