@@ -216,6 +216,12 @@ extension Auth: AuthInterop {
216
216
/// The tenant ID of the auth instance. `nil` if none is available.
217
217
@objc open var tenantID : String ?
218
218
219
+ /// When true, route all RPCs to identityplatform.googleapis.com (R‑GCIP).
220
+ @objc open var useIdentityPlatform : Bool = false
221
+
222
+ /// Regional prefix (e.g. "us‑east4") for R‑GCIP endpoints.
223
+ @objc open var location : String ?
224
+
219
225
/// The custom authentication domain used to handle all sign-in redirects.
220
226
/// End-users will see
221
227
/// this domain when signing in. This domain must be allowlisted in the Firebase Console.
@@ -2425,3 +2431,36 @@ extension Auth: AuthInterop {
2425
2431
/// Mutations should occur within a @synchronized(self) context.
2426
2432
private var listenerHandles : NSMutableArray = [ ]
2427
2433
}
2434
+
2435
+ extension Auth {
2436
+ /// Exchange a third‑party OIDC token for a short‑lived Firebase STS token.
2437
+ @objc open func exchangeToken(
2438
+ _ idpConfigID: String ,
2439
+ _ ciamOidcToken: String ,
2440
+ completion: @escaping ( String ? , Error ? ) -> Void
2441
+ ) {
2442
+ // Must have opted into R‑GCIP
2443
+ guard useIdentityPlatform,
2444
+ let _ = location,
2445
+ let _ = tenantID
2446
+ else {
2447
+ completion ( nil , AuthErrorUtils . operationNotAllowedError (
2448
+ message: " Set useIdentityPlatform=true, location & tenantID first " ) )
2449
+ return
2450
+ }
2451
+
2452
+ let req = ExchangeOIDCTokenRequest (
2453
+ idpConfigID: idpConfigID,
2454
+ idToken: ciamOidcToken,
2455
+ cfg: requestConfiguration
2456
+ )
2457
+ Task {
2458
+ do {
2459
+ let resp = try await backend. call ( with: req)
2460
+ DispatchQueue . main. async { completion ( resp. firebaseToken, nil ) }
2461
+ } catch {
2462
+ DispatchQueue . main. async { completion ( nil , error) }
2463
+ }
2464
+ }
2465
+ }
2466
+ }
0 commit comments