Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[google_sign_in] Fix issue obtaining serverAuthCode on Android and add forceCodeForRefreshToken parameter #3356

Merged
merged 25 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b73d66e
[force-code-for-refresh-token-new] Add forceCodeForRefreshToken to al…
fbcouch Jan 11, 2022
1c1e639
[force-code-for-refresh-token] Add AUTHORS
fbcouch Jan 11, 2022
8b0e62f
[force-code-for-refresh-token] Update to non-breaking change for plat…
fbcouch Jan 12, 2022
56949bd
[force-code-for-refresh-token] Clean up a couple things
fbcouch Jan 12, 2022
00c9788
[force-code-for-refresh-token] Run flutter format
fbcouch Jan 12, 2022
f37e9c4
[force-code-for-refresh-token] Add dependency_overrides to example pr…
fbcouch Jan 12, 2022
39982f1
[force-code-for-refresh-token] Java format
fbcouch Jan 12, 2022
4ca9194
[force-code-for-refresh-token] Correct path in example apps
fbcouch Jan 12, 2022
7a2b9e0
[force-code-for-refresh-token] Update CHANGELOG entries
fbcouch Jan 14, 2022
40d32f7
[force-code-for-refresh-token] Add dependency override for web
fbcouch Jan 31, 2022
b70f335
[force-code-for-refresh-token] Refactor GoogleSignInPlugin.Delegate t…
fbcouch Jan 31, 2022
4f95091
[force-code-for-refresh-token] Split true/false flows into separate t…
fbcouch Feb 14, 2022
e2d28df
[force-code-for-refresh-token] Merge branch 'main' into force-code-fo…
fbcouch Apr 22, 2022
dfdbd31
[force-code-for-refresh-token] Merge branch 'main' into force-code-fo…
fbcouch May 11, 2022
6a979fb
[force-code-for-refresh-token] Fix up after merging the the platform …
fbcouch May 11, 2022
f9de832
[force-code-for-refresh-token] Correct interface versions and changelogs
fbcouch May 11, 2022
9a18677
[force-code-for-refresh-token] Fix formatting issues
fbcouch May 12, 2022
aec0d6e
[force-code-for-refresh-token] One more formatting change
fbcouch May 12, 2022
76abc28
[force-code-for-refresh-token] Fix up merge conflicts
fbcouch May 12, 2022
4fcc78f
[force-code-for-refresh-token] Merge branch 'main' into force-code-fo…
fbcouch Jul 21, 2022
7a859c7
[force-code-for-refresh-token] Clean up after merge
fbcouch Jul 21, 2022
63d78e7
[force-code-for-refresh-token] Add to main flutter-plugins AUTHORS
fbcouch Jul 21, 2022
5ffd375
[force-code-for-refresh-token] [force-code-for-refresh-token-platform…
fbcouch Jul 21, 2022
e1fa17d
[force-code-for-refresh-token] Merge branch 'main' into force-code-fo…
fbcouch Sep 2, 2022
2d79cc6
[force-code-for-refresh-token] Revert android/ios changes to the publ…
fbcouch Sep 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ Daniel Roek <daniel.roek@gmail.com>
TheOneWithTheBraid <the-one@with-the-braid.cf>
Rulong Chen(陈汝龙) <rulong.crl@alibaba-inc.com>
Hwanseok Kang <tttkhs96@gmail.com>
Twin Sun, LLC <google-contrib@twinsunsolutions.com>
1 change: 1 addition & 0 deletions packages/google_sign_in/google_sign_in/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ Aleksandr Yurkovskiy <sanekyy@gmail.com>
Anton Borries <mail@antonborri.es>
Alex Li <google@alexv525.com>
Rahul Raj <64.rahulraj@gmail.com>
Twin Sun, LLC <google-contrib@twinsunsolutions.com>
4 changes: 3 additions & 1 deletion packages/google_sign_in/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## NEXT
## 5.4.2

* Updates minimum Flutter version to 2.10.
* Adds override for `GoogleSignInPlatform.initWithParams`.
* Fixes tests to recognize new default `forceCodeForRefreshToken` request attribute.

## 5.4.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,16 @@ class GoogleSignIn {
/// The [hostedDomain] argument specifies a hosted domain restriction. By
/// setting this, sign in will be restricted to accounts of the user in the
/// specified domain. By default, the list of accounts will not be restricted.
///
/// The [forceCodeForRefreshToken] is used on Android to ensure the authentication
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for specifying this is an android-only thing here!

/// code can be exchanged for a refresh token after the first request.
GoogleSignIn({
this.signInOption = SignInOption.standard,
this.scopes = const <String>[],
this.hostedDomain,
this.clientId,
this.serverClientId,
this.forceCodeForRefreshToken = false,
});

/// Factory for creating default sign in user experience.
Expand Down Expand Up @@ -250,6 +254,9 @@ class GoogleSignIn {
/// server.
final String? serverClientId;

/// Force the authorization code to be valid for a refresh token every time. Only needed on Android.
final bool forceCodeForRefreshToken;

final StreamController<GoogleSignInAccount?> _currentUserController =
StreamController<GoogleSignInAccount?>.broadcast();

Expand Down Expand Up @@ -286,6 +293,7 @@ class GoogleSignIn {
hostedDomain: hostedDomain,
clientId: clientId,
serverClientId: serverClientId,
forceCodeForRefreshToken: forceCodeForRefreshToken,
))
..catchError((dynamic _) {
// Invalidate initialization if it errors out.
Expand Down
6 changes: 3 additions & 3 deletions packages/google_sign_in/google_sign_in/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android and iOS.
repository: https://github.com/flutter/plugins/tree/main/packages/google_sign_in/google_sign_in
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 5.4.1
version: 5.4.2


environment:
Expand All @@ -23,8 +23,8 @@ flutter:
dependencies:
flutter:
sdk: flutter
google_sign_in_android: ^6.0.0
google_sign_in_ios: ^5.4.0
google_sign_in_android: ^6.1.0
google_sign_in_ios: ^5.5.0
google_sign_in_platform_interface: ^2.2.0
google_sign_in_web: ^0.10.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ void main() {
verify(mockPlatform.signIn());
});

test('forceCodeForRefreshToken sent with init method call', () async {
final GoogleSignIn googleSignIn =
GoogleSignIn(forceCodeForRefreshToken: true);

await googleSignIn.signIn();

_verifyInit(mockPlatform, forceCodeForRefreshToken: true);
verify(mockPlatform.signIn());
});

test('signOut', () async {
final GoogleSignIn googleSignIn = GoogleSignIn();

Expand Down