Skip to content

Commit b2e33fd

Browse files
Merge branch 'flutter:main' into webview_flutter_android_set-Web-Authentication-Support
2 parents a43bb7d + d060692 commit b2e33fd

32 files changed

Lines changed: 400 additions & 265 deletions

File tree

.ci/flutter_master.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3598686e42e37134209fa9df8223d9cbaaf513da
1+
259aeae0e0bacc37b4cfc70c9f5d2d0e83706261

.ci/flutter_stable.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
00b0c91f06209d9e4a41f71b7a512d6eb3b9c694
1+
559ffa3f75e7402d65a8def9c28389a9b2e6fe42

packages/google_sign_in/google_sign_in_android/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 7.2.11
2+
3+
* Bumps AndroidX Credentials to v1.6.0
4+
* Bumps Play Services Auth to v21.5.1
5+
* Bumps Android Identity GoogleID to v1.2.0
6+
17
## 7.2.10
28

39
* Updates build files from Groovy to Kotlin.

packages/google_sign_in/google_sign_in_android/android/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ android {
7171
}
7272

7373
dependencies {
74-
implementation("androidx.credentials:credentials:1.5.0")
75-
implementation("androidx.credentials:credentials-play-services-auth:1.5.0")
76-
implementation("com.google.android.libraries.identity.googleid:googleid:1.1.1")
77-
implementation("com.google.android.gms:play-services-auth:21.4.0")
74+
implementation("androidx.credentials:credentials:1.6.0")
75+
implementation("androidx.credentials:credentials-play-services-auth:1.6.0")
76+
implementation("com.google.android.libraries.identity.googleid:googleid:1.2.0")
77+
implementation("com.google.android.gms:play-services-auth:21.5.1")
7878
testImplementation("junit:junit:4.13.2")
7979
testImplementation("org.mockito:mockito-core:5.23.0")
8080
}

packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ public void onResult(GetCredentialResponse response) {
287287
googleIdTokenCredential.getDisplayName(),
288288
googleIdTokenCredential.getFamilyName(),
289289
googleIdTokenCredential.getGivenName(),
290-
googleIdTokenCredential.getId(),
290+
googleIdTokenCredential.getEmail(),
291291
googleIdTokenCredential.getIdToken(),
292292
profilePictureUri == null ? null : profilePictureUri.toString())));
293293
} else {
@@ -384,7 +384,9 @@ public void authorize(
384384
}
385385
if (params.getServerClientIdForForcedRefreshToken() != null) {
386386
authorizationRequestBuilder.requestOfflineAccess(
387-
params.getServerClientIdForForcedRefreshToken(), true);
387+
params.getServerClientIdForForcedRefreshToken());
388+
// This requests a new refresh token
389+
authorizationRequestBuilder.setPrompt(AuthorizationRequest.Prompt.CONSENT);
388390
}
389391
if (params.getAccountEmail() != null) {
390392
authorizationRequestBuilder.setAccount(

packages/google_sign_in/google_sign_in_android/android/src/main/kotlin/io/flutter/plugins/googlesignin/Messages.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ data class PlatformGoogleIdTokenCredential(
331331
val displayName: String? = null,
332332
val familyName: String? = null,
333333
val givenName: String? = null,
334-
val id: String,
334+
val email: String,
335335
val idToken: String,
336336
val profilePictureUri: String? = null
337337
) {
@@ -340,11 +340,11 @@ data class PlatformGoogleIdTokenCredential(
340340
val displayName = pigeonVar_list[0] as String?
341341
val familyName = pigeonVar_list[1] as String?
342342
val givenName = pigeonVar_list[2] as String?
343-
val id = pigeonVar_list[3] as String
343+
val email = pigeonVar_list[3] as String
344344
val idToken = pigeonVar_list[4] as String
345345
val profilePictureUri = pigeonVar_list[5] as String?
346346
return PlatformGoogleIdTokenCredential(
347-
displayName, familyName, givenName, id, idToken, profilePictureUri)
347+
displayName, familyName, givenName, email, idToken, profilePictureUri)
348348
}
349349
}
350350

@@ -353,7 +353,7 @@ data class PlatformGoogleIdTokenCredential(
353353
displayName,
354354
familyName,
355355
givenName,
356-
id,
356+
email,
357357
idToken,
358358
profilePictureUri,
359359
)

packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInTest.java

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ public void getCredential_returnsAuthenticationInfo() {
187187
final String displayName = "Jane User";
188188
final String givenName = "Jane";
189189
final String familyName = "User";
190-
final String id = "someId";
190+
final String email = "someEmail";
191191
final String idToken = "idToken";
192192
when(mockGoogleCredential.getDisplayName()).thenReturn(displayName);
193193
when(mockGoogleCredential.getGivenName()).thenReturn(givenName);
194194
when(mockGoogleCredential.getFamilyName()).thenReturn(familyName);
195-
when(mockGoogleCredential.getId()).thenReturn(id);
195+
when(mockGoogleCredential.getEmail()).thenReturn(email);
196196
when(mockGoogleCredential.getIdToken()).thenReturn(idToken);
197197

198198
final Boolean[] callbackCalled = new Boolean[1];
@@ -210,7 +210,7 @@ public void getCredential_returnsAuthenticationInfo() {
210210
assertEquals(displayName, credential.getDisplayName());
211211
assertEquals(givenName, credential.getGivenName());
212212
assertEquals(familyName, credential.getFamilyName());
213-
assertEquals(id, credential.getId());
213+
assertEquals(email, credential.getEmail());
214214
assertEquals(idToken, credential.getIdToken());
215215
return null;
216216
}));
@@ -833,8 +833,7 @@ public void authorize_returnsImmediateResult() {
833833

834834
callbackCaptor
835835
.getValue()
836-
.onSuccess(
837-
new AuthorizationResult(serverAuthCode, accessToken, "idToken", scopes, null, null));
836+
.onSuccess(mockSuccessAuthorizationResult(serverAuthCode, accessToken, scopes));
838837
assertTrue(callbackCalled[0]);
839838
}
840839

@@ -894,10 +893,7 @@ public void authorize_reportsFailureIfUnauthorizedAndNoPromptAllowed() {
894893
ArgumentCaptor.forClass(OnSuccessListener.class);
895894
verify(mockAuthorizationTask).addOnSuccessListener(callbackCaptor.capture());
896895

897-
callbackCaptor
898-
.getValue()
899-
.onSuccess(
900-
new AuthorizationResult(null, null, null, scopes, null, mockAuthorizationIntent));
896+
callbackCaptor.getValue().onSuccess(mockResolutionAuthorizationResult(mockAuthorizationIntent));
901897
assertTrue(callbackCalled[0]);
902898
}
903899

@@ -931,10 +927,7 @@ public void authorize_reportsFailureIfUnauthorizedAndNoActivity() {
931927
ArgumentCaptor.forClass(OnSuccessListener.class);
932928
verify(mockAuthorizationTask).addOnSuccessListener(callbackCaptor.capture());
933929

934-
callbackCaptor
935-
.getValue()
936-
.onSuccess(
937-
new AuthorizationResult(null, null, null, scopes, null, mockAuthorizationIntent));
930+
callbackCaptor.getValue().onSuccess(mockResolutionAuthorizationResult(mockAuthorizationIntent));
938931
assertTrue(callbackCalled[0]);
939932
}
940933

@@ -947,10 +940,11 @@ public void authorize_returnsPostIntentResult() {
947940
final String accessToken = "accessToken";
948941
final String serverAuthCode = "serverAuthCode";
949942
when(mockAuthorizationClient.authorize(any())).thenReturn(mockAuthorizationTask);
943+
AuthorizationResult successResult =
944+
mockSuccessAuthorizationResult(serverAuthCode, accessToken, scopes);
950945
try {
951946
when(mockAuthorizationClient.getAuthorizationResultFromIntent(any()))
952-
.thenReturn(
953-
new AuthorizationResult(serverAuthCode, accessToken, "idToken", scopes, null, null));
947+
.thenReturn(successResult);
954948
} catch (ApiException e) {
955949
fail();
956950
}
@@ -977,10 +971,7 @@ public void authorize_returnsPostIntentResult() {
977971
ArgumentCaptor<OnSuccessListener<AuthorizationResult>> callbackCaptor =
978972
ArgumentCaptor.forClass(OnSuccessListener.class);
979973
verify(mockAuthorizationTask).addOnSuccessListener(callbackCaptor.capture());
980-
callbackCaptor
981-
.getValue()
982-
.onSuccess(
983-
new AuthorizationResult(null, null, null, scopes, null, mockAuthorizationIntent));
974+
callbackCaptor.getValue().onSuccess(mockResolutionAuthorizationResult(mockAuthorizationIntent));
984975
try {
985976
verify(mockActivity)
986977
.startIntentSenderForResult(
@@ -1044,10 +1035,7 @@ public void authorize_reportsPendingIntentException() {
10441035
ArgumentCaptor<OnSuccessListener<AuthorizationResult>> callbackCaptor =
10451036
ArgumentCaptor.forClass(OnSuccessListener.class);
10461037
verify(mockAuthorizationTask).addOnSuccessListener(callbackCaptor.capture());
1047-
callbackCaptor
1048-
.getValue()
1049-
.onSuccess(
1050-
new AuthorizationResult(null, null, null, scopes, null, mockAuthorizationIntent));
1038+
callbackCaptor.getValue().onSuccess(mockResolutionAuthorizationResult(mockAuthorizationIntent));
10511039

10521040
assertTrue(callbackCalled[0]);
10531041
}
@@ -1087,10 +1075,7 @@ public void authorize_reportsPostIntentException() {
10871075
ArgumentCaptor<OnSuccessListener<AuthorizationResult>> callbackCaptor =
10881076
ArgumentCaptor.forClass(OnSuccessListener.class);
10891077
verify(mockAuthorizationTask).addOnSuccessListener(callbackCaptor.capture());
1090-
callbackCaptor
1091-
.getValue()
1092-
.onSuccess(
1093-
new AuthorizationResult(null, null, null, scopes, null, mockAuthorizationIntent));
1078+
callbackCaptor.getValue().onSuccess(mockResolutionAuthorizationResult(mockAuthorizationIntent));
10941079
try {
10951080
verify(mockActivity)
10961081
.startIntentSenderForResult(
@@ -1203,4 +1188,21 @@ public void clearAuthorizationToken_callsClient() {
12031188
ClearTokenRequest request = authRequestCaptor.getValue();
12041189
assertEquals(testToken, request.getToken());
12051190
}
1191+
1192+
private AuthorizationResult mockSuccessAuthorizationResult(
1193+
String serverAuthCode, String accessToken, List<String> scopes) {
1194+
AuthorizationResult mockResult = mock(AuthorizationResult.class);
1195+
when(mockResult.hasResolution()).thenReturn(false);
1196+
when(mockResult.getAccessToken()).thenReturn(accessToken);
1197+
when(mockResult.getServerAuthCode()).thenReturn(serverAuthCode);
1198+
when(mockResult.getGrantedScopes()).thenReturn(scopes);
1199+
return mockResult;
1200+
}
1201+
1202+
private AuthorizationResult mockResolutionAuthorizationResult(PendingIntent pendingIntent) {
1203+
AuthorizationResult mockResult = mock(AuthorizationResult.class);
1204+
when(mockResult.hasResolution()).thenReturn(true);
1205+
when(mockResult.getPendingIntent()).thenReturn(pendingIntent);
1206+
return mockResult;
1207+
}
12061208
}

packages/google_sign_in/google_sign_in_android/lib/google_sign_in_android.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ class GoogleSignInAndroid extends GoogleSignInPlatform {
237237
// Store a preliminary entry using the 'openid' scope, which in practice
238238
// always seems to be granted at authentication time, so that an account
239239
// that is authenticated but never authorized can still be disconnected.
240-
_cachedAccounts[authnResult.credential.id] = 'openid';
240+
_cachedAccounts[authnResult.credential.email] = 'openid';
241241
return authnResult.credential;
242242
}
243243
}
@@ -320,7 +320,7 @@ class GoogleSignInAndroid extends GoogleSignInPlatform {
320320
// The ID should always be availabe from the token, but if for some reason
321321
// it can't be extracted, use the email address instead as a reasonable
322322
// fallback method of identifying the account.
323-
final String email = credential.id;
323+
final String email = credential.email;
324324
final String userId = _idFromIdToken(credential.idToken) ?? email;
325325

326326
return AuthenticationResults(

packages/google_sign_in/google_sign_in_android/lib/src/messages.g.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class PlatformGoogleIdTokenCredential {
330330
this.displayName,
331331
this.familyName,
332332
this.givenName,
333-
required this.id,
333+
required this.email,
334334
required this.idToken,
335335
this.profilePictureUri,
336336
});
@@ -341,7 +341,7 @@ class PlatformGoogleIdTokenCredential {
341341

342342
String? givenName;
343343

344-
String id;
344+
String email;
345345

346346
String idToken;
347347

@@ -352,7 +352,7 @@ class PlatformGoogleIdTokenCredential {
352352
displayName,
353353
familyName,
354354
givenName,
355-
id,
355+
email,
356356
idToken,
357357
profilePictureUri,
358358
];
@@ -368,7 +368,7 @@ class PlatformGoogleIdTokenCredential {
368368
displayName: result[0] as String?,
369369
familyName: result[1] as String?,
370370
givenName: result[2] as String?,
371-
id: result[3]! as String,
371+
email: result[3]! as String,
372372
idToken: result[4]! as String,
373373
profilePictureUri: result[5] as String?,
374374
);

packages/google_sign_in/google_sign_in_android/pigeons/messages.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class PlatformGoogleIdTokenCredential {
9191
String? displayName;
9292
String? familyName;
9393
String? givenName;
94-
late String id;
94+
late String email;
9595
late String idToken;
9696
String? profilePictureUri;
9797
}

0 commit comments

Comments
 (0)