-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[google_sign_in] Redesign API for current identity SDKs #9267
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
Open
stuartmorgan-g
wants to merge
49
commits into
flutter:main
Choose a base branch
from
stuartmorgan-g:google-sign-in-authn-authz-redesign
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
432a627
Initial PoC using CredentialManager
stuartmorgan-g df1cf87
Pathify everything for local development
stuartmorgan-g 6a1ec7c
Remove method channel implementation
stuartmorgan-g 49342c5
First pass rework of interface, impls, and app-facing API
stuartmorgan-g eba7a8b
Add nonce support
stuartmorgan-g f3d472f
Initial README updates and migration guide
stuartmorgan-g 728a4f9
Rework Android calls to match recommended practice
stuartmorgan-g c165834
Synthesize sign-out event for disconnect
stuartmorgan-g dba0f3e
platform interface tests
stuartmorgan-g 83c7b1d
Simplify Android Pigeon API
stuartmorgan-g 82c0530
Android Dart unit tests
stuartmorgan-g 4123b18
iOS Dart unit tests
stuartmorgan-g 165fb78
Web Dart 'unit' tests, and fix lightweight auth return
stuartmorgan-g eda66bb
Update example apps
stuartmorgan-g 21635a0
Update native unit tests, fix an Obj-C selector name
stuartmorgan-g 39b7505
Update to recent 1.5 release
stuartmorgan-g 07fe543
Android native unit tests
stuartmorgan-g e6c9f62
README, CHANGELOG, and version updates
stuartmorgan-g 90a63aa
App-facing Dart tests
stuartmorgan-g 816f614
Revert unrelated Xcode project changes
stuartmorgan-g 0d46beb
Analysis fix
stuartmorgan-g a0cf078
Revert extension package changes
stuartmorgan-g 0a134ec
Fix Obj-C warnings
stuartmorgan-g 1b0d4d1
Missing license
stuartmorgan-g 8f57604
Analyze fix
stuartmorgan-g e786998
Update excerpting
stuartmorgan-g 78602e8
Merge branch 'main' into google-sign-in-authn-authz-redesign
stuartmorgan-g 8783b72
Merge branch 'main' into google-sign-in-authn-authz-redesign
stuartmorgan-g 7140fd0
Remove email scope
stuartmorgan-g 5a587b4
Web README additions
stuartmorgan-g 5f78e10
Update stream error handling, update main example
stuartmorgan-g a6036b8
Fix lightweight auth null return, and add missing tests
stuartmorgan-g 9c9923c
Re-add web asserts for scope spaces
stuartmorgan-g b44ff39
Remove unused People code
stuartmorgan-g 8640443
Restructure options slightly
stuartmorgan-g 86a7a1d
Add TODO issue link
stuartmorgan-g 4fb7fea
Add activity lifecycle tests
stuartmorgan-g 563680c
Add authorize param tests
stuartmorgan-g dab117f
Test safety check, better README
stuartmorgan-g 81f59f7
Analyzer
stuartmorgan-g 6b76be0
Java autoformat
stuartmorgan-g 9817325
excerpt update
stuartmorgan-g 20a8fc5
Add stack traces to stream errors
stuartmorgan-g d6bd8bc
Handle emulators without sign-in support
stuartmorgan-g 6766860
Add another missing stack
stuartmorgan-g 8ad0051
Rework the stream tests to make wasm happy
stuartmorgan-g 98e55b2
Merge branch 'main' into google-sign-in-authn-authz-redesign
stuartmorgan-g f36a6c8
Minor iOS review fixes
stuartmorgan-g 2823a54
Add authorizationRequiresUserInteraction
stuartmorgan-g File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Migrating from `google_sign_in` 6.x to 7.x | ||
|
||
The API of `google_sign_in` 6.x and earlier was designed for the Google Sign-In | ||
SDK, which has been deprecated on both Android and Web, and replaced with new | ||
SDKs that have significantly different structures. As a result, the | ||
`google_sign_in` API surface has changed significantly. Notable differences | ||
include: | ||
* `GoogleSignIn` is now a singleton, which is obtained via | ||
`GoogleSignIn.instance`. In practice, creating multiple `GoogleSignIn` | ||
instances in 6.x would not work correctly, so this just enforces an existing | ||
restriction. | ||
* There is now an explicit `initialize` step that must be called exactly once, | ||
before any other methods. On some platforms the future will complete almost | ||
immediately, but on others (for example, web) it may take some time. | ||
* The plugin no longer tracks a single "current" signed in user. Instead, | ||
applications that assume a single signed in user should track this at the | ||
application level using the `authenticationEvents` stream. | ||
* Authentication (signing in) and authorization (allowing access to user data | ||
in the form of scopes) are now separate steps. Recommended practice is to | ||
authenticate as soon as it makes sense for a user to potentially be signed in, | ||
but to delay authorization until the point where the data will actually be | ||
used. | ||
* In applications where these steps should happen at the same time, you can | ||
pass a `scopeHint` during the authentication step. On platforms that support | ||
it this allows for a combined authentication and authorization UI flow. | ||
Not all platforms allow combining these flows, so your application should be | ||
prepared to trigger a separate authorization prompt if necessary. | ||
* Authorization is further separated into client and server authorization. | ||
Applications that need a `serverAuthCode` must now call a separate method, | ||
`authorizeServer`, to obtain that code. | ||
* Client authorization is handled via two new methods: | ||
* `authorizationForScopes`, which returns an access token if the requested | ||
scopes are already authorized, or null if not, and | ||
* `authorizeScopes`, which requests that the user authorize the scopes, and | ||
is expected to show UI. | ||
|
||
Clients should generally attempt to get tokens via `authorizationForScopes`, | ||
and if they are unable to do so, show some UI to request authoriaztion that | ||
calls `authorizeScopes`. This is similar to the previously web-only flow | ||
of calling `canAccessScopes` and then calling `addScopes` if necessary. | ||
* `signInSilently` has been replaced with `attemptLightweightAuthentication`. | ||
The intended usage is essentially the same, but the change reflects that it | ||
is no longer guaranteed to be silent. For example, as of the publishing of | ||
7.0, on web this may show a floating sign-in card, and on Android it may show | ||
an account selection sheet. | ||
* This new method is no longer guaranteed to return a future. This allows | ||
clients to distinguish, at runtime: | ||
* platforms where a definitive "signed in" or "not signed in" response | ||
can be returned quickly, and thus `await`-ing completion is reasonable, | ||
in which case a `Future` is returned, and | ||
* platforms (such as web) where it could take an arbitrary amount of time, | ||
in which case no `Future` is returned, and clients should assume a | ||
non-signed-in state until/unless a sign-in event is eventually posted to | ||
the `authenticationEvents` stream. | ||
* `authenticate` replaces the authentication portion of `signIn` on platforms | ||
that support it (see below). | ||
* The new `supportsAuthenticate` method allows clients to determine at runtime | ||
whether the `authenticate` method is supported, as some platforms do not allow | ||
custom UI to trigger explicit authentication. These platforms instead provide | ||
some other platform-specific way of triggering authentication. As of | ||
publishing, the only platform that does not support `authenticate` is web, | ||
where `google_sign_in_web`'s `renderButton` is used to create a sign-in | ||
button. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Upon re-reading this... is this paragraph is a little bit incomplete? IIRC The authentication token (idToken) is also not refreshed, so both authorization and authentication end up expiring, right?
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.
Looks that way. I can adjust the README accordingly, but maybe you just didn't mention it because normally (IIUC) clients don't need to keep using ID tokens they way they do access tokens.
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.
Added a similar note in the authentication section, but pointing out that for authentication generally you should only need to use
idToken
when it's first received.