From e9fcf6b7bc21e93dd0f8f3f39573852dcea69625 Mon Sep 17 00:00:00 2001 From: Gimun Kim <101035437+kmkim2689@users.noreply.github.com> Date: Tue, 6 Aug 2024 21:47:01 +0900 Subject: [PATCH] :bug: adding Bearer prefix when getting access token from data store --- .../datasource/auth/DefaultSessionLocalDataSource.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/java/net/pengcook/android/data/datasource/auth/DefaultSessionLocalDataSource.kt b/android/app/src/main/java/net/pengcook/android/data/datasource/auth/DefaultSessionLocalDataSource.kt index 4dfe55e6..414e34f3 100644 --- a/android/app/src/main/java/net/pengcook/android/data/datasource/auth/DefaultSessionLocalDataSource.kt +++ b/android/app/src/main/java/net/pengcook/android/data/datasource/auth/DefaultSessionLocalDataSource.kt @@ -27,7 +27,13 @@ class DefaultSessionLocalDataSource( } override suspend fun updateAccessToken(accessToken: String?) { - dataStore.modifyValue(KEY_ACCESS_TOKEN, accessToken) + val token = + if (accessToken != null) { + "${PREFIX_BEARER_TOKEN}$accessToken" + } else { + null + } + dataStore.modifyValue(KEY_ACCESS_TOKEN, token) } override suspend fun updateRefreshToken(refreshToken: String?) { @@ -89,6 +95,7 @@ class DefaultSessionLocalDataSource( companion object { private const val TAG = "DefaultAuthorizationLocalDataSource" + private const val PREFIX_BEARER_TOKEN = "Bearer " private const val EXCEPTION_ERROR_READING_EXCEPTION = "Error reading preferences." private val KEY_ACCESS_TOKEN = stringPreferencesKey("access_token") private val KEY_REFRESH_TOKEN = stringPreferencesKey("refresh_token")