@@ -13,11 +13,11 @@ public class GoogleProviderSwift: @preconcurrency GoogleProviderProtocol {
1313 public init ( scopes: [ String ] ? = nil ) {
1414 self . scopes = scopes ?? kDefaultScopes
1515 }
16-
16+
1717 public func handleUrl( _ url: URL ) -> Bool {
1818 return GIDSignIn . sharedInstance. handle ( url)
1919 }
20-
20+
2121 @MainActor public func signInWithGoogle( clientID: String ) async throws -> AuthCredential {
2222 guard let presentingViewController = ( UIApplication . shared. connectedScenes
2323 . first as? UIWindowScene ) ? . windows. first? . rootViewController else {
@@ -29,34 +29,35 @@ public class GoogleProviderSwift: @preconcurrency GoogleProviderProtocol {
2929 ]
3030 )
3131 }
32-
32+
3333 let config = GIDConfiguration ( clientID: clientID)
3434 GIDSignIn . sharedInstance. configuration = config
3535
3636 return try await withCheckedThrowingContinuation { continuation in
37- GIDSignIn . sharedInstance. signIn (
38- withPresenting: presentingViewController
39- ) { result, error in
40- if let error = error {
41- continuation. resume ( throwing: error)
42- return
43- }
44-
45- guard let user = result? . user,
46- let idToken = user. idToken? . tokenString else {
47- continuation. resume ( throwing: NSError (
48- domain: " GoogleProviderSwiftErrorDomain " ,
49- code: 2 ,
50- userInfo: [
51- NSLocalizedDescriptionKey: " Failed to retrieve user or idToken. " ,
52- ]
53- ) )
54- return
55- }
56-
57- let credential = GoogleAuthProvider . credential ( withIDToken: idToken,
58- accessToken: user. accessToken. tokenString)
59- continuation. resume ( returning: credential)
37+ GIDSignIn . sharedInstance. signIn (
38+ withPresenting: presentingViewController
39+ ) { result, error in
40+ if let error = error {
41+ continuation. resume ( throwing: error)
42+ return
6043 }
44+
45+ guard let user = result? . user,
46+ let idToken = user. idToken? . tokenString else {
47+ continuation. resume ( throwing: NSError (
48+ domain: " GoogleProviderSwiftErrorDomain " ,
49+ code: 2 ,
50+ userInfo: [
51+ NSLocalizedDescriptionKey: " Failed to retrieve user or idToken. " ,
52+ ]
53+ ) )
54+ return
55+ }
56+
57+ let credential = GoogleAuthProvider . credential ( withIDToken: idToken,
58+ accessToken: user. accessToken. tokenString)
59+ continuation. resume ( returning: credential)
60+ }
61+ }
6162 }
6263}
0 commit comments