Skip to content

Adding Sample App Changes #14985

New issue

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

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

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: exchange-token-tests
Choose a base branch
from

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.

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 pashanka and ncooke3 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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants