From 275d6f3ce8d4bc8b17a10c70b5dd0642cba54ef3 Mon Sep 17 00:00:00 2001 From: Kaung Khant Soe Date: Fri, 6 Jan 2023 13:07:02 +0700 Subject: [PATCH] [#228] Remove redundant functions in SessionManager --- .../nimblehq/template/xml/data/service/SessionManager.kt | 4 ---- .../authenticator/ApplicationRequestAuthenticator.kt | 8 ++------ 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/SessionManager.kt b/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/SessionManager.kt index 55c39704b..1e21a0075 100644 --- a/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/SessionManager.kt +++ b/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/SessionManager.kt @@ -8,9 +8,5 @@ interface SessionManager { suspend fun getRefreshToken(): String - suspend fun getRegistrationToken(): String - - suspend fun getTokenType(): String - suspend fun refresh(authenticateResponse: AuthenticateResponse) } diff --git a/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/authenticator/ApplicationRequestAuthenticator.kt b/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/authenticator/ApplicationRequestAuthenticator.kt index 9e3b0161d..c2ee59bb7 100644 --- a/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/authenticator/ApplicationRequestAuthenticator.kt +++ b/template-xml/data/src/main/java/co/nimblehq/template/xml/data/service/authenticator/ApplicationRequestAuthenticator.kt @@ -40,14 +40,10 @@ class ApplicationRequestAuthenticator( } else { retryCount++ - val tokenType = sessionManager.getTokenType() val failedAccessToken = sessionManager.getAccessToken() try { - val refreshTokenResponse = tokenRefresher.refreshToken().last().copy( - // refreshToken response doesn't send tokenType - tokenType = tokenType - ) + val refreshTokenResponse = tokenRefresher.refreshToken().last() val newAccessToken = refreshTokenResponse.accessToken if (newAccessToken.isEmpty() || newAccessToken == failedAccessToken) { @@ -61,7 +57,7 @@ class ApplicationRequestAuthenticator( // Retry this failed request (401) with the new token return@runBlocking response.request .newBuilder() - .header(REQUEST_HEADER_AUTHORIZATION, "$tokenType $newAccessToken") + .header(REQUEST_HEADER_AUTHORIZATION, newAccessToken) .build() } catch (e: Exception) { Log.w("AUTHENTICATOR", "Failed to refresh token: $e")