Skip to content

Update Auth.swift #14744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions FirebaseAuth/Sources/Swift/Auth/Auth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@
/// The tenant ID of the auth instance. `nil` if none is available.
@objc open var tenantID: String?

/// When true, route all RPCs to identityplatform.googleapis.com (R‑GCIP).
@objc open var useIdentityPlatform: Bool = false

/// Regional prefix (e.g. "us‑east4") for R‑GCIP endpoints.
@objc open var location: String?

/// The custom authentication domain used to handle all sign-in redirects.
/// End-users will see
/// this domain when signing in. This domain must be allowlisted in the Firebase Console.
Expand Down Expand Up @@ -2425,3 +2431,36 @@
/// Mutations should occur within a @synchronized(self) context.
private var listenerHandles: NSMutableArray = []
}

extension Auth {
/// Exchange a third‑party OIDC token for a short‑lived Firebase STS token.
@objc open func exchangeToken(
_ idpConfigID: String,
_ ciamOidcToken: String,
completion: @escaping (String?, Error?) -> Void
) {
// Must have opted into R‑GCIP
guard useIdentityPlatform,
let _ = location,
let _ = tenantID
else {
completion(nil, AuthErrorUtils.operationNotAllowedError(
message: "Set useIdentityPlatform=true, location & tenantID first"))
return
}

let req = ExchangeOIDCTokenRequest(

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, watchOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, macOS spmbuildonly)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-14, Xcode_16.2, iOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, catalyst spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, visionOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope

Check failure on line 2452 in FirebaseAuth/Sources/Swift/Auth/Auth.swift

View workflow job for this annotation

GitHub Actions / spm (macos-15, Xcode_16.3, tvOS spm)

cannot find 'ExchangeOIDCTokenRequest' in scope
idpConfigID: idpConfigID,
idToken: ciamOidcToken,
cfg: requestConfiguration
)
Task {
do {
let resp = try await backend.call(with: req)
DispatchQueue.main.async { completion(resp.firebaseToken, nil) }
} catch {
DispatchQueue.main.async { completion(nil, error) }
}
}
}
}
Loading