From 8f0d9dac55e8dee2acc12f6f414abf05c0430aa5 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Fri, 8 Nov 2024 14:44:56 -0800 Subject: [PATCH] Fix logic inconsistency between 10.x and 11.x --- FirebaseAuth/Sources/Swift/User/User.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/FirebaseAuth/Sources/Swift/User/User.swift b/FirebaseAuth/Sources/Swift/User/User.swift index 94d1c13dd0a..282843c80ab 100644 --- a/FirebaseAuth/Sources/Swift/User/User.swift +++ b/FirebaseAuth/Sources/Swift/User/User.swift @@ -1598,18 +1598,22 @@ extension User: NSSecureCoding {} /// Retrieves the Firebase authentication token, possibly refreshing it if it has expired. /// - Parameter forceRefresh func internalGetTokenAsync(forceRefresh: Bool = false) async throws -> String { + var keychainError = false do { let (token, tokenUpdated) = try await tokenService.fetchAccessToken( forcingRefresh: forceRefresh ) if tokenUpdated { if let error = updateKeychain() { + keychainError = true throw error } } return token! } catch { - signOutIfTokenIsInvalid(withError: error) + if !keychainError { + signOutIfTokenIsInvalid(withError: error) + } throw error } }