diff --git a/.changeset/bright-lamps-sign.md b/.changeset/bright-lamps-sign.md new file mode 100644 index 00000000000..72e5133bf16 --- /dev/null +++ b/.changeset/bright-lamps-sign.md @@ -0,0 +1,5 @@ +--- +'@clerk/expo': patch +--- + +Fixes iOS Google One Tap sign-in to reject blank Google client IDs and to default to filtering by previously authorized accounts. diff --git a/packages/expo/ios/ClerkGoogleSignInModule.swift b/packages/expo/ios/ClerkGoogleSignInModule.swift index 8a43a346d38..c08bd79d106 100644 --- a/packages/expo/ios/ClerkGoogleSignInModule.swift +++ b/packages/expo/ios/ClerkGoogleSignInModule.swift @@ -32,8 +32,8 @@ public class ClerkGoogleSignInModule: Module { // MARK: - configure private func configure(_ params: [String: Any?]) { - let webClientId = params["webClientId"] as? String ?? "" - let iosClientId = params["iosClientId"] as? String + let webClientId = self.nonEmptyClientId(params["webClientId"] as? String) + let iosClientId = self.nonEmptyClientId(params["iosClientId"] as? String) self.clientId = iosClientId ?? webClientId self.hostedDomain = params["hostedDomain"] as? String @@ -59,7 +59,7 @@ public class ClerkGoogleSignInModule: Module { return } - let filterByAuthorized = params?["filterByAuthorizedAccounts"] as? Bool ?? false + let filterByAuthorized = params?["filterByAuthorizedAccounts"] as? Bool ?? true let hint: String? = filterByAuthorized ? GIDSignIn.sharedInstance.currentUser?.profile?.email : nil @@ -137,6 +137,14 @@ public class ClerkGoogleSignInModule: Module { // MARK: - Helpers + private func nonEmptyClientId(_ value: String?) -> String? { + guard let value = value?.trimmingCharacters(in: .whitespacesAndNewlines) else { + return nil + } + + return value.isEmpty ? nil : value + } + private func getPresentingViewController() -> UIViewController? { guard let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let window = scene.windows.first,