Skip to content

Commit 0006c76

Browse files
authored
Update Auth.swift
rgcip flags
1 parent b321674 commit 0006c76

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

FirebaseAuth/Sources/Swift/Auth/Auth.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ extension Auth: AuthInterop {
216216
/// The tenant ID of the auth instance. `nil` if none is available.
217217
@objc open var tenantID: String?
218218

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+
219225
/// The custom authentication domain used to handle all sign-in redirects.
220226
/// End-users will see
221227
/// this domain when signing in. This domain must be allowlisted in the Firebase Console.
@@ -2425,3 +2431,36 @@ extension Auth: AuthInterop {
24252431
/// Mutations should occur within a @synchronized(self) context.
24262432
private var listenerHandles: NSMutableArray = []
24272433
}
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

Comments
 (0)