Skip to content

feat(ui_oauth_google)!: migrate to google_sign_in 7 - #689

Merged
demolaf merged 3 commits into
firebase:mainfrom
bjrochem72:google-sign-in-7
Sep 15, 2026
Merged

demolaf merged 3 commits into
firebase:mainfrom
bjrochem72:google-sign-in-7

Conversation

@bjrochem72

@bjrochem72 bjrochem72 commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Description

Migrates firebase_ui_oauth_google from google_sign_in 6.x to 7.x.

google_sign_in 6.x pins apps to google_sign_in_ios 5.x, which still uses the deprecated UIApplication delegate lifecycle. Moving to 7.x resolves google_sign_in_ios 6.3.x, which adopted the UIScene lifecycle in 6.3.0 and added a Swift Package Manager target in 6.3.3. This clears the FLTGoogleSignInPlugin deprecation warning that iOS apps currently log on startup.

What changed:

  • GoogleProvider now uses the shared GoogleSignIn.instance and initializes it once before the first sign-in.
  • Authentication and authorization are separate steps in google_sign_in 7. When scopes are requested, the provider first tries authorizationForScopes and falls back to authorizeScopes, so the resulting Firebase credential still carries an access token as it did in 6.x. When no scopes are requested the credential contains only an ID token, which is all Firebase Auth needs.
  • A cancelled sign-in (GoogleSignInExceptionCode.canceled) is surfaced as AuthCancelledException, so the auth flow resets exactly as before.
  • New optional serverClientId parameter on GoogleProvider, GoogleSignInButton and GoogleSignInIconButton. On Android an ID token requires a server client ID. Apps that use google-services.json containing a web OAuth client entry need no change; other apps can now pass it explicitly.
  • The existing integration test is migrated to mock the new API.

The constraint is ^7.1.0 because 7.1.0 added the GoogleSignInExceptionCode export needed for structured cancel handling.

Verified locally on the workspace: dart analyze reports no problems, firebase_ui_oauth (7/7) and firebase_ui_auth (69/69) test suites pass, and the tests package compiles against the migrated API.

Related Issues

Fixes #673. Related to the wider UIScene migration alongside #672 / #676.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • All unit tests pass (melos run test:unit:all doesn't fail).
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request upgrades the google_sign_in dependency to version ^7.1.0 and introduces support for serverClientId in GoogleSignInButton, GoogleSignInIconButton, and GoogleProvider. It refactors GoogleProvider to align with the new plugin API, separating authentication and authorization steps and adding initialization logic. Feedback suggests exposing a @visibleForTesting method to reset the static _initialization state to ensure test isolation, as well as simplifying the _ensureInitialized method by chaining the .catchError call directly.

Comment thread packages/firebase_ui_oauth_google/lib/src/provider.dart
Comment thread packages/firebase_ui_oauth_google/lib/src/provider.dart
bjrochem72 added a commit to bjrochem72/FirebaseUI-Flutter that referenced this pull request Sep 8, 2026
Chain the retry-reset catchError directly onto initialize() instead of
threading an intermediate local, and add a @VisibleForTesting
debugReset() that clears the static one-time-init future so each test
starts from a clean state with its freshly injected mock.

Addresses review feedback on firebase#689.
@bjrochem72

Copy link
Copy Markdown
Contributor Author

Pushed a couple of follow-ups to get CI green:

  • Format (code_health): reformatted provider.dart — it was the only file dart format flagged.
  • Android (e2e): the build was failing at :firebase_auth:compileDebugKotlin with "requires a newer version of the Kotlin Gradle plugin". google_sign_in_android 7 is built with Kotlin 2.3, so I bumped the Kotlin Gradle plugin in tests/android from 2.1.02.3.0.
  • iOS/macOS (e2e): pod install couldn't resolve FirebaseFirestore — the harness pins the precompiled frameworks at 12.15.0, but cloud_firestore 6.9.0 needs ~> 12.18.0, so I bumped that pin to 12.18.0. (This one was already red on main, so it should help there too.)

The new workflow runs are showing action_required — could a maintainer approve them so we can confirm the e2e jobs? Thanks!

@demolaf
demolaf self-requested a review September 14, 2026 13:38

@demolaf demolaf left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. There's already a PR to resolve CI failing on main #692.

Once that's in, you can keep this PR focused on it's own work.

@bjrochem72

Copy link
Copy Markdown
Contributor Author

Thanks for the review @demolaf! I've dropped the Firestore pod bump — #692 covers the iOS/macOS CI on main, so this PR now stays focused on the google_sign_in 7 migration (plus the Android Kotlin bump it needs). Happy to rebase once #692 lands.

@bjrochem72

bjrochem72 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

CI update

#692 has landed on main and owns the iOS/macOS pod install fix — the FirebaseFirestore precompiled-frameworks pin (now 12.18.0), together with exact firebase_core / cloud_firestore pins in tests/pubspec.yaml.

Correcting my earlier note: the 12.19.0 figure came from this branch, not main. This branch's tests/pubspec.yaml still floated cloud_firestore: ^6.6.0, which resolved to 6.10.0 and pulled Firebase SDK 12.19.0, conflicting with the 12.18.0 pod pin. main itself is self-consistent — exact cloud_firestore: 6.9.0 / firebase_core: 4.14.0 line up with the 12.18.0 Podfile pin — so no further bump is needed there.

I'm rebasing onto latest main, which inherits those exact pins and clears the Firestore conflict. The Android Kotlin 2.3.0 bump also already landed on main, so I've dropped it here — this PR is now just the firebase_ui_oauth_google google_sign_in 7 migration.

This will be the first run where pod install gets past Firestore and actually exercises google_sign_in 7's native side, so I'll keep an eye on the iOS/macOS result.

bjrochem72 and others added 3 commits September 14, 2026 16:40
Migrates GoogleProvider to the google_sign_in 7 API, which adopts the
UIScene lifecycle on iOS (google_sign_in_ios 6.3.0) and Swift Package
Manager (6.3.3). Fixes the deprecated application lifecycle warning
tracked in firebase#673.

- GoogleSignIn is now the shared instance and is initialized once
  before the first sign-in.
- Authentication and authorization are separate steps. The provider
  reuses an existing authorization for the requested scopes and prompts
  for consent when one is not available, so the credential still
  carries an access token when scopes are requested.
- A cancelled sign-in surfaces as AuthCancelledException, matching the
  previous flow reset behaviour.
- Adds an optional serverClientId parameter to GoogleProvider,
  GoogleSignInButton and GoogleSignInIconButton for Android apps that
  do not use google-services.json.
- Updates the integration test mocks to the new API.

BREAKING CHANGE: consumers must follow the google_sign_in 7 platform
integration steps: GIDClientID in Info.plist on iOS, and on Android a
web OAuth client entry in google-services.json or an explicit
serverClientId. When no scopes are requested the credential now
contains only an ID token.
Chain the retry-reset catchError directly onto initialize() instead of
threading an intermediate local, and add a @VisibleForTesting
debugReset() that clears the static one-time-init future so each test
starts from a clean state with its freshly injected mock.

Addresses review feedback on firebase#689.
@bjrochem72

Copy link
Copy Markdown
Contributor Author

The rebased run is green on web, Android and macOS. iOS came back red on a single test — Firebase UI Firestore › FirestoreListViewBuilder › By default, ignore errors — which passed on macOS in the same run, so it reads as a flake rather than a regression. It lives in firebase_ui_firestore, which this PR doesn't touch.

The google_sign_in 7 path itself passed on iOS, including "signs the user in" and "works standalone" (37 passed, 1 failed, 9 skipped).

I don't have re-run rights on the repo as an external contributor — could a maintainer kick off a re-run of the iOS job when convenient? Happy to rebase again if you'd prefer that to re-trigger it.

@demolaf
demolaf merged commit 5ba5c70 into firebase:main Sep 15, 2026
28 of 29 checks passed
@russellwheatley

Copy link
Copy Markdown
Member

Hey @bjrochem72 - really sorry, we took this off main because we're going to do a breaking change release around 30th September. We're going to cut a normal release today. If you'd like to reopen a new PR with the exact same changes, we can merge it after today's release.

@bjrochem72

Copy link
Copy Markdown
Contributor Author

Thanks @russellwheatley, understood. Reopened as #700 with the same changes, rebased onto current main — ready to merge there after today's release.

demolaf pushed a commit that referenced this pull request Sep 17, 2026
* feat(ui_oauth_google)!: migrate to google_sign_in 7

Migrates GoogleProvider to the google_sign_in 7 API, which adopts the
UIScene lifecycle on iOS (google_sign_in_ios 6.3.0) and Swift Package
Manager (6.3.3). Fixes the deprecated application lifecycle warning
tracked in #673.

- GoogleSignIn is now the shared instance and is initialized once
  before the first sign-in.
- Authentication and authorization are separate steps. The provider
  reuses an existing authorization for the requested scopes and prompts
  for consent when one is not available, so the credential still
  carries an access token when scopes are requested.
- A cancelled sign-in surfaces as AuthCancelledException, matching the
  previous flow reset behaviour.
- Adds an optional serverClientId parameter to GoogleProvider,
  GoogleSignInButton and GoogleSignInIconButton for Android apps that
  do not use google-services.json.
- Updates the integration test mocks to the new API.

BREAKING CHANGE: consumers must follow the google_sign_in 7 platform
integration steps: GIDClientID in Info.plist on iOS, and on Android a
web OAuth client entry in google-services.json or an explicit
serverClientId. When no scopes are requested the credential now
contains only an ID token.

* refactor(ui_oauth_google): simplify init and isolate it in tests

Chain the retry-reset catchError directly onto initialize() instead of
threading an intermediate local, and add a @VisibleForTesting
debugReset() that clears the static one-time-init future so each test
starts from a clean state with its freshly injected mock.

Addresses review feedback on #689.

* chore(ui_oauth_google): format provider.dart

* fix(ui_oauth_google): preserve stack trace on init retry

Use Error.throwWithStackTrace in the initialize() catchError so a failed initialization keeps its original stack trace instead of resetting it with a bare throw.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

firebase_ui_oauth_google: adopt google_sign_in 7.x (UIScene support; 6.x uses deprecated lifecycle events)

3 participants