-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[google_sign_in] Implement clearAuthorizationToken #10024
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
[google_sign_in] Implement clearAuthorizationToken #10024
Conversation
Adds a new `clearAuthCache` method to the `google_sign_in` plugin. This method allows developers to clear the auth cache for a signed-in user. The implementation is provided for the Android and Web platforms. On Android, it calls `AuthorizationClient.clearToken`. On Web, it removes the matching entry from an in-memory cache.
|
No changes from the main PR, which already has platform review, so @bparrishMines this just needs a sanity check. |
There was a problem hiding this 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 introduces the clearAuthorizationToken method across Android, iOS, and web platforms for the google_sign_in plugin. The Android implementation leverages the native clearToken API, the iOS version is a no-op as the SDK handles token invalidation automatically, and the web version clears a local token cache. The changes include necessary dependency updates, pigeon interface modifications, and tests for the new functionality. My feedback includes a suggestion to use a more conventional error code format in the Android implementation for better maintainability.
| e -> | ||
| ResultUtilsKt.completeWithUnitError( | ||
| callback, | ||
| new FlutterError("clearAuthorizationToken failed", e.getMessage(), null))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error code "clearAuthorizationToken failed" is rather long and descriptive for an error code. It's more conventional to use a short, machine-readable string (e.g., in snake_case or kebab-case). This would improve consistency with common error handling patterns and make it easier for clients to programmatically handle this specific error.
For instance, clearCredentialState uses "Clear Failed", which is shorter. A more structured code like clear_authorization_token_failed would be even better for consistency and parsing.
| new FlutterError("clearAuthorizationToken failed", e.getMessage(), null))); | |
| new FlutterError("clear_authorization_token_failed", e.getMessage(), null))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we ever start seeing this in practice, this should be switched over to using structured errors anyway; we don't want people doing programatic handling of error code strings that are already inconsistent within and across platform implementations (which is why the structured error guidance exists now). So I didn't worry about making this match anything.
mdebbar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
web bits look good to me!
|
Oops, I forgot the main PR didn't have web approval; thanks for catching that and reviewing here! |
flutter/packages@0255ac9...fdee698 2025-09-17 [email protected] [google_sign_in] Implement clearAuthorizationToken (flutter/packages#10024) 2025-09-17 [email protected] Roll Flutter (stable) from a402d9a to d693b4b (6 revisions) (flutter/packages#10026) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump androidx.exifinterface:exifinterface from 1.3.7 to 1.4.1 in /packages/image_picker/image_picker_android/android (flutter/packages#10008) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump com.google.code.gson:gson from 2.11.0 to 2.13.2 in /packages/espresso/android (flutter/packages#10006) 2025-09-16 [email protected] Update web plugin owners (flutter/packages#9994) 2025-09-16 [email protected] Roll Flutter from 29a238d to 8d0b31d (19 revisions) (flutter/packages#10019) 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 [email protected] 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
flutter/packages@0255ac9...fdee698 2025-09-17 [email protected] [google_sign_in] Implement clearAuthorizationToken (flutter/packages#10024) 2025-09-17 [email protected] Roll Flutter (stable) from a402d9a to d693b4b (6 revisions) (flutter/packages#10026) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump androidx.exifinterface:exifinterface from 1.3.7 to 1.4.1 in /packages/image_picker/image_picker_android/android (flutter/packages#10008) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump com.google.code.gson:gson from 2.11.0 to 2.13.2 in /packages/espresso/android (flutter/packages#10006) 2025-09-16 [email protected] Update web plugin owners (flutter/packages#9994) 2025-09-16 [email protected] Roll Flutter from 29a238d to 8d0b31d (19 revisions) (flutter/packages#10019) 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 [email protected] 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
flutter/packages@0255ac9...fdee698 2025-09-17 [email protected] [google_sign_in] Implement clearAuthorizationToken (flutter/packages#10024) 2025-09-17 [email protected] Roll Flutter (stable) from a402d9a to d693b4b (6 revisions) (flutter/packages#10026) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump androidx.exifinterface:exifinterface from 1.3.7 to 1.4.1 in /packages/image_picker/image_picker_android/android (flutter/packages#10008) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump com.google.code.gson:gson from 2.11.0 to 2.13.2 in /packages/espresso/android (flutter/packages#10006) 2025-09-16 [email protected] Update web plugin owners (flutter/packages#9994) 2025-09-16 [email protected] Roll Flutter from 29a238d to 8d0b31d (19 revisions) (flutter/packages#10019) 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 [email protected] 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
flutter/packages@0255ac9...fdee698 2025-09-17 [email protected] [google_sign_in] Implement clearAuthorizationToken (flutter/packages#10024) 2025-09-17 [email protected] Roll Flutter (stable) from a402d9a to d693b4b (6 revisions) (flutter/packages#10026) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump androidx.exifinterface:exifinterface from 1.3.7 to 1.4.1 in /packages/image_picker/image_picker_android/android (flutter/packages#10008) 2025-09-16 49699333+dependabot[bot]@users.noreply.github.com [dependabot]: Bump com.google.code.gson:gson from 2.11.0 to 2.13.2 in /packages/espresso/android (flutter/packages#10006) 2025-09-16 [email protected] Update web plugin owners (flutter/packages#9994) 2025-09-16 [email protected] Roll Flutter from 29a238d to 8d0b31d (19 revisions) (flutter/packages#10019) 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 [email protected] 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
Platform interface portion of #9846
Part of flutter/flutter#173924
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
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