Skip to content
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

[gsi_web] Do not initialize CodeClient if scopes are empty. #5537

Merged
merged 3 commits into from
Dec 2, 2023

Conversation

ditman
Copy link
Member

@ditman ditman commented Dec 1, 2023

When initializing a CodeClient, it is mandatory to pass at least one scope (or the JS initialization will crash).

This PR ensures that the CodeClient is not created unless initialScopes.isNotEmpty, and lets the user know when attempting to use said client that it hasn't been initialized properly.

Issues

Tests

  • Tested locally with cocoon.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie or stuartmorgan on the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

I haven't paged the whole flow back in here, but what if someone creates with no scopes, but then adds scopes later. Shouldn't we create the client then? Or does that already happen?

packages/google_sign_in/google_sign_in_web/CHANGELOG.md Outdated Show resolved Hide resolved
@ditman
Copy link
Member Author

ditman commented Dec 1, 2023

I haven't paged the whole flow back in here, but what if someone creates with no scopes, but then adds scopes later. Shouldn't we create the client then? Or does that already happen?

This is not happening right now, but YES, it seems that for incremental authorization you're supposed to re-create the client every time.

This was not clear while developing this, because include_granted_scopes is one of the properties that got added without us noticing (I'm tracking that in a separate issue).

For now, clients will have to pass the scopes beforehand, but later we can treat the plugin as a factory of CodeClients, or just re-create the Code Client right before the user does getServerCode(List<String> scopes) or similar.

Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM with TODO nit.

@ditman
Copy link
Member Author

ditman commented Dec 2, 2023

@stuartmorgan if all the pre-submit tests pass I'm going to land this with the tree on red. I don't think it's going to fix the tree, but... it might kick a lucky build and fix. That way we can continue working on google_sign_in_web without worrying about publishing the bad version (the migration to package:web, for example).

@ditman ditman added warning: land on red to fix tree breakage Override tree-status signal (land even with closed tree), combine with the autosubmit label. autosubmit Merge PR when tree becomes green via auto submit App labels Dec 2, 2023
@auto-submit auto-submit bot merged commit 74925d9 into flutter:main Dec 2, 2023
79 of 80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Dec 4, 2023
flutter/packages@bc72d15...5d9874f

2023-12-02 [email protected] Roll Flutter from 918e336 to d861ce4 (29 revisions) (flutter/packages#5542)
2023-12-02 [email protected] [gsi_web] Do not initialize CodeClient if scopes are empty. (flutter/packages#5537)
2023-12-01 [email protected] Reenable macOS 13 tests (flutter/packages#5494)
2023-12-01 [email protected] [flutter_image] Adopt code excerpts in README (flutter/packages#5498)
2023-11-30 [email protected] [cross_file] Migrate to pkg:web, bump min SDK to Dart 3.2 (flutter/packages#5520)
2023-11-30 [email protected] [google_maps_flutter] Add support for version 8 of the iOS SDK (flutter/packages#5528)
2023-11-30 [email protected] [pointer_interceptor] Re-land: Add platform interface (flutter/packages#5525)
2023-11-30 [email protected] [google_sign_in] Add server auth code retrieval to gis_client (flutter/packages#5358)
2023-11-30 [email protected] Roll Flutter from 5e5b529 to 918e336 (14 revisions) (flutter/packages#5526)

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],[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
@ditman ditman deleted the fix-gsi-web-api branch December 5, 2023 02:15
HugoOlthof pushed a commit to moneybird/packages that referenced this pull request Dec 13, 2023
…5537)

When initializing a `CodeClient`, it is mandatory to pass at least one `scope` (or the JS initialization will crash).

This PR ensures that the `CodeClient` is not created unless `initialScopes.isNotEmpty`, and lets the user know when attempting to use said client that it hasn't been initialized properly.

## Issues

* Fixes: flutter/flutter#139382
* Fixes: flutter/flutter#62474
* Closes: flutter/cocoon#3304 (makes this PR unneeded)

## Tests

* Tested locally with `cocoon`.
@reidbaker reidbaker mentioned this pull request Jan 12, 2024
arc-yong pushed a commit to Arctuition/packages-arc that referenced this pull request Jun 14, 2024
…5537)

When initializing a `CodeClient`, it is mandatory to pass at least one `scope` (or the JS initialization will crash).

This PR ensures that the `CodeClient` is not created unless `initialScopes.isNotEmpty`, and lets the user know when attempting to use said client that it hasn't been initialized properly.

## Issues

* Fixes: flutter/flutter#139382
* Fixes: flutter/flutter#62474
* Closes: flutter/cocoon#3304 (makes this PR unneeded)

## Tests

* Tested locally with `cocoon`.
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-web warning: land on red to fix tree breakage Override tree-status signal (land even with closed tree), combine with the autosubmit label.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[infra][cocoon] Unable to use the dashboard Google Sign In 4.5.1 - ServerAuthCode returns null value for Web
2 participants