Skip to content

Commit

Permalink
[#228] Remove redundant functions in SessionManager
Browse files Browse the repository at this point in the history
  • Loading branch information
kaungkhantsoe committed Jan 6, 2023
1 parent 8a867f0 commit 275d6f3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,5 @@ interface SessionManager {

suspend fun getRefreshToken(): String

suspend fun getRegistrationToken(): String

suspend fun getTokenType(): String

suspend fun refresh(authenticateResponse: AuthenticateResponse)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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")
Expand Down

0 comments on commit 275d6f3

Please sign in to comment.