From 467556d75ce445f5394f3f7dd54477781f72632c Mon Sep 17 00:00:00 2001 From: Hugh Daschbach Date: Fri, 15 Dec 2023 17:45:47 -0800 Subject: [PATCH] Suppress some authentication noise in the log. Most of this was added to debug issue !102. So these are vestigial. The exception here is the handling of AuthorizationException type 2. These are produced by racing authentication requests and are successfully managed. So we need not report these. Part-of: --- .../java/audio/funkwhale/ffa/utils/Extensions.kt | 12 ++++-------- app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt b/app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt index 2e53712..9f46206 100644 --- a/app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt +++ b/app/src/main/java/audio/funkwhale/ffa/utils/Extensions.kt @@ -53,9 +53,6 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request { this@authorize.apply { if (!Settings.isAnonymous()) { oAuth.state().let { state -> - state.accessTokenExpirationTime?.let { - Log.i("Request.authorize()", "Accesstoken expiration: ${Date(it).format()}") - } val old = state.accessToken val auth = ClientSecretPost(oAuth.state().clientSecret) val done = CompletableDeferred() @@ -64,10 +61,9 @@ fun Request.authorize(context: Context, oAuth: OAuth): Request { state.performActionWithFreshTokens(tokenService, auth) { token, _, e -> if (e != null) { Log.e("Request.authorize()", "performActionWithFreshToken failed: $e") - Log.e("Request.authorize()", Log.getStackTraceString(e)) - } - if (token == old) { - Log.i("Request.authorize()", "Accesstoken not renewed") + if (e.type != 2 || e.code != 2002) { + Log.e("Request.authorize()", Log.getStackTraceString(e)) + } } if (token != old && token != null) { state.save() @@ -150,4 +146,4 @@ inline fun LiveData.mergeWith( } } -public fun String?.toIntOrElse(default: Int): Int = this?.toIntOrNull(radix = 10) ?: default \ No newline at end of file +public fun String?.toIntOrElse(default: Int): Int = this?.toIntOrNull(radix = 10) ?: default diff --git a/app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt b/app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt index 19560ed..e36a0ea 100644 --- a/app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt +++ b/app/src/main/java/audio/funkwhale/ffa/utils/OAuth.kt @@ -83,7 +83,7 @@ class OAuth(private val authorizationServiceFactory: AuthorizationServiceFactory refreshAccessToken(state, context) } else { state.isAuthorized - }.also { it.logInfo("tryRefreshAccessToken()") } + } } return false }