@@ -2484,8 +2484,8 @@ public extension Auth {
24842484 idpConfigId: String ,
24852485 completion: @escaping ( AuthTokenResult ? , Error ? ) -> Void ) {
24862486 // Ensure R-GCIP is configured with location and tenant ID
2487- guard let location = requestConfiguration. location,
2488- let tenantId = requestConfiguration. tenantId
2487+ guard let _ = requestConfiguration. location,
2488+ let _ = requestConfiguration. tenantId
24892489 else {
24902490 completion ( nil , AuthErrorCode . operationNotAllowed)
24912491 return
@@ -2504,19 +2504,15 @@ public extension Auth {
25042504 let response = try await backend. call ( with: request)
25052505 do {
25062506 // Try to parse the Firebase token response
2507- let authTokenResult = try AuthTokenResult . tokenResult ( token: response. firebaseToken)
2508- DispatchQueue . main. async {
2507+ do {
2508+ let authTokenResult = try AuthTokenResult . tokenResult ( token: response. firebaseToken)
2509+ completion ( authTokenResult, nil )
25092510 completion ( authTokenResult, nil )
25102511 }
25112512 } catch {
2512- // Failed to parse JWT
2513- DispatchQueue . main. async {
2514- completion ( nil , AuthErrorCode . malformedJWT)
2515- }
2516- }
2517- } catch {
2518- // Backend call failed
2519- DispatchQueue . main. async {
2513+ completion ( nil , AuthErrorCode . malformedJWT)
2514+ } catch {
2515+ // 5. Handle other errors (network, server errors, etc.).
25202516 completion ( nil , error)
25212517 }
25222518 }
@@ -2539,8 +2535,8 @@ public extension Auth {
25392535 /// or if the token parsing fails.
25402536 func exchangeToken( idToken: String , idpConfigId: String ) async throws -> AuthTokenResult {
25412537 // Ensure R-GCIP is configured with location and tenant ID
2542- guard let location = requestConfiguration. location,
2543- let tenantId = requestConfiguration. tenantId
2538+ guard let _ = requestConfiguration. location,
2539+ let _ = requestConfiguration. tenantId
25442540 else {
25452541 throw AuthErrorCode . operationNotAllowed
25462542 }
@@ -2553,7 +2549,11 @@ public extension Auth {
25532549 )
25542550
25552551 // Perform the backend call and return parsed token
2556- let response = try await backend. call ( with: request)
2557- return try AuthTokenResult . tokenResult ( token: response. firebaseToken)
2552+ do {
2553+ let response = try await backend. call ( with: request)
2554+ return try AuthTokenResult . tokenResult ( token: response. firebaseToken)
2555+ } catch {
2556+ throw error
2557+ }
25582558 }
25592559}
0 commit comments