Skip to content

Conversation

@stuartmorgan-g
Copy link
Collaborator

Fixes an issue where serverAuthorizationTokensForScopes would usually return the results of getRefreshedAuthorizationTokens directly, even though getRefreshedAuthorizationTokens will never include a server auth code. Now, the server auth code is cached when it is returned from authn steps, so that it can be returned when it is requested, since those are different APIs in this plugin (unlike the underlying SDK on iOS).

Fixes flutter/flutter#175313

Pre-Review Checklist

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2 3

Fixes an issue where `serverAuthorizationTokensForScopes` would usually
return the results of `getRefreshedAuthorizationTokens` directly, even
though `getRefreshedAuthorizationTokens` will never include a server
auth code. Now, the server auth code is cached when it is returned from
authn steps, so that it can be returned when it is requested, since
those are different APIs in this plugin (unlike the underlying SDK on
iOS).

Fixes flutter/flutter#175313
Copy link

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

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 fixes an issue on iOS where serverAuthorizationTokensForScopes would incorrectly return null. The fix introduces caching for the server authorization code, ensuring it's available for later calls. The implementation is sound, correctly handling user changes by associating the cached code with a user ID. The accompanying tests are thorough, covering the new caching logic and various edge cases. I've added one suggestion to improve the readability of a new test case.


/// The user identifier for the cached server auth code, to ensure that a
/// cached code isn't returned across users.
String? _cachedServerAuthCodeUserId;
Copy link
Contributor

Choose a reason for hiding this comment

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

The cache doesn't seem to be invalidated on logout?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! For signOut it's probably harmless since the grant should still be active, but it definitely shouldn't be returned after disconnect, and since I can't think of any reason someone should expect to get it after signOut I'll go ahead and clear it there.

Also added cache unit tests for both signOut and disconnect that would have caught this.

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

One comment regarding cache invalidation otherwise LGTM.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 18, 2025
@auto-submit auto-submit bot merged commit 4272600 into flutter:main Sep 18, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Sep 19, 2025
flutter/packages@f2a65fd...3d5c419

2025-09-19 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump camerax_version from 1.5.0-rc01 to 1.5.0 in
/packages/camera/camera_android_camerax/android (flutter/packages#10009)
2025-09-18 stuartmorgan@google.com [google_sign_in] Fix iOS sever auth
codes (flutter/packages#10021)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Jaineel-Mamtora pushed a commit to Jaineel-Mamtora/flutter_forked that referenced this pull request Sep 24, 2025
…r#175668)

flutter/packages@f2a65fd...3d5c419

2025-09-19 49699333+dependabot[bot]@users.noreply.github.com
[dependabot]: Bump camerax_version from 1.5.0-rc01 to 1.5.0 in
/packages/camera/camera_android_camerax/android (flutter/packages#10009)
2025-09-18 stuartmorgan@google.com [google_sign_in] Fix iOS sever auth
codes (flutter/packages#10021)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC flutter-ecosystem@google.com on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: google_sign_in platform-ios

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[google_sign_in] Server auth code is always null on iOS after authenticate

2 participants