From 9e3103aa225d51533dc869a12316d6fc86a0120a Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Sat, 27 Apr 2024 23:46:24 +0200 Subject: [PATCH] Robustify getIdToken --- .../androidmakers/store/firebase/FirebaseUserRepository.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/firebase/FirebaseUserRepository.kt b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/firebase/FirebaseUserRepository.kt index 2cdd2df1..b9a2d23c 100644 --- a/shared/data/src/commonMain/kotlin/fr/androidmakers/store/firebase/FirebaseUserRepository.kt +++ b/shared/data/src/commonMain/kotlin/fr/androidmakers/store/firebase/FirebaseUserRepository.kt @@ -31,7 +31,12 @@ class FirebaseUserRepository : UserRepository { } override suspend fun getIdToken(): String? { - return currentUser.value?.getIdToken(false) + return try { + currentUser.value?.getIdToken(false) + } catch (e: Exception) { + // See https://github.com/firebase/firebase-android-sdk/issues/5328#issuecomment-1719386926 + null + } } override suspend fun setUser(user: Any?) {