Skip to content

Conversation

@srushtisv
Copy link
Contributor

@srushtisv srushtisv commented Jun 14, 2025

Description

This PR updates the FirebaseAuth test app AuthenticationExample to include a new menu item for testing the "Exchange Token" feature, which is part of the Bring Your Own CIAM (BYO-CIAM) support for Regionalized GCIP.

Changes:

  • AuthMenu.swift: Added a new case .exchangeToken and a corresponding section exchangeTokenSection.
  • AuthViewController.swift:
    • Added handling for the .exchangeToken case in didSelectRowAt.
    • Implemented the callExchangeToken() function, which prompts the user for an "OIDC Token" and "IDP Config ID" using showTextInputPrompt.
    • Calls the auth().exchangeToken() async method with the provided inputs and useStaging: true.
    • Displays success or error messages using showAlert.
  • AppManager.swift: Modified the auth() method to return an Auth instance configured with a default TenantConfig("tenantId", "prod-global"). This is necessary for the exchangeToken calls to target a regionalized endpoint.

To provide a way to manually test and demonstrate the new Auth.exchangeToken() SDK methods within the sample application AuthenticationExample environment.

Testing:

Manual testing steps:

  1. Run the Sample AuthenticationExample app.
  2. Navigate to the "Exchange Token [Regionalized]" section.
  3. Tap "Exchange Token".
  4. Enter a test OIDC token and IDP Configuration ID when prompted.
  5. Observe the alert indicating success or failure. Check console logs for details.

Also, corrects accessToken in ExchangeTokenResponse.

@gemini-code-assist

This comment was marked as resolved.

@google-oss-bot
Copy link

google-oss-bot commented Jun 14, 2025

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

@srushtisv srushtisv self-assigned this Jun 16, 2025
@srushtisv srushtisv marked this pull request as ready for review June 16, 2025 07:53
@srushtisv srushtisv requested review from ncooke3 and pashanka June 16, 2025 07:53
@@ -1,4 +1,4 @@
// Copyright 2025 Google LLC
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nick, Just a typo on my part — fixed it.

Comment on lines 1100 to 1122
// 1. Prompt for the custom OIDC token and await user input.
guard let idToken = await showTextInputPrompt(with: "Enter OIDC Token:") else {
print("Token exchange cancelled: OIDC Token was not provided.")
// Present an alert on the main thread to indicate cancellation.
DispatchQueue.main.async {
let alert = UIAlertController(title: "Cancelled",
message: "An OIDC Token is required to proceed.",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
self.present(alert, animated: true)
}
return
}

// 2. Prompt for the IDP Config ID and await user input.
guard let idpConfigId = await showTextInputPrompt(with: "Enter IDP Config ID:") else {
print("Token exchange cancelled: IDP Config ID was not provided.")
// Present an alert on the main thread to indicate cancellation.
DispatchQueue.main.async {
let alert = UIAlertController(title: "Cancelled",
message: "An IDP Config ID is required to proceed.",
preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Shouldn't the order of this prompt be the other way, get the idpConfigId first and then it's corresponding token?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes Pavan, this would be more intuitive. I’ll reorder the prompt.

@srushtisv srushtisv requested review from ncooke3 and pashanka June 23, 2025 21:26
@srushtisv srushtisv force-pushed the exchange-token-tests branch from accdbd0 to 13ebcaa Compare June 24, 2025 08:14
@srushtisv srushtisv force-pushed the byociam-sample-app-implementation branch from 80647da to 859ec86 Compare June 24, 2025 08:25
@srushtisv srushtisv force-pushed the exchange-token-tests branch from 13ebcaa to 0d97ade Compare June 24, 2025 11:38
@srushtisv srushtisv force-pushed the byociam-sample-app-implementation branch from a42c578 to d958c95 Compare June 24, 2025 12:37
@srushtisv
Copy link
Contributor Author

duplicate of #15040

@srushtisv srushtisv closed this Jun 24, 2025
@firebase firebase locked and limited conversation to collaborators Jul 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants