Skip to content

Commit b35ffc1

Browse files
yamarkzEgor
authored andcommitted
[google_sign_in_platform_interface] Add serverAuthCode attribute. (flutter#2634)
This change adds the `serverAuthCode` attribute to the `GoogleSignInTokenData` class. Usage: ``` // Sign in somewhere, then... final tokens = await _googleSignIn.getTokens(); final serverAuthCode = tokens.serverAuthCode; // serverAuthCode may be used by your server ```
1 parent 6f65c6f commit b35ffc1

File tree

6 files changed

+21
-6
lines changed

6 files changed

+21
-6
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,4 @@ Nissim Dsilva <nissim@tengio.com>
5454
Giancarlo Rocha <giancarloiff@gmail.com>
5555
Ryo Miyake <ryo@miyake.id>
5656
Théo Champion <contact.theochampion@gmail.com>
57+
Kazuki Yamaguchi <y.kazuki0614n@gmail.com>

packages/google_sign_in/google_sign_in_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.1
2+
3+
* Add attribute serverAuthCode.
4+
15
## 1.1.0
26

37
* Add hasRequestedScope method to determine if an Oauth scope has been granted.

packages/google_sign_in/google_sign_in_platform_interface/lib/src/types.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,31 @@ class GoogleSignInUserData {
8282
/// Holds authentication data after sign in.
8383
class GoogleSignInTokenData {
8484
/// Either or both parameters may be null.
85-
GoogleSignInTokenData({this.idToken, this.accessToken});
85+
GoogleSignInTokenData({
86+
this.idToken,
87+
this.accessToken,
88+
this.serverAuthCode,
89+
});
8690

8791
/// An OpenID Connect ID token for the authenticated user.
8892
String idToken;
8993

9094
/// The OAuth2 access token used to access Google services.
9195
String accessToken;
9296

97+
/// Server auth code used to access Google Login
98+
String serverAuthCode;
99+
93100
@override
94-
int get hashCode => hash2(idToken, accessToken);
101+
int get hashCode => hash3(idToken, accessToken, serverAuthCode);
95102

96103
@override
97104
bool operator ==(dynamic other) {
98105
if (identical(this, other)) return true;
99106
if (other is! GoogleSignInTokenData) return false;
100107
final GoogleSignInTokenData otherTokenData = other;
101108
return otherTokenData.idToken == idToken &&
102-
otherTokenData.accessToken == accessToken;
109+
otherTokenData.accessToken == accessToken &&
110+
otherTokenData.serverAuthCode == serverAuthCode;
103111
}
104112
}

packages/google_sign_in/google_sign_in_platform_interface/lib/src/utils.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ GoogleSignInTokenData getTokenDataFromMap(Map<String, dynamic> data) {
2525
return GoogleSignInTokenData(
2626
idToken: data['idToken'],
2727
accessToken: data['accessToken'],
28+
serverAuthCode: data['serverAuthCode'],
2829
);
2930
}

packages/google_sign_in/google_sign_in_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the google_sign_in plugin.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/google_sign_in/google_sign_in_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 1.1.0
6+
version: 1.1.1
77

88
dependencies:
99
flutter:

packages/google_sign_in/google_sign_in_platform_interface/test/method_channel_google_sign_in_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
import 'package:flutter/services.dart';
6+
import 'package:flutter_test/flutter_test.dart';
57
import 'package:google_sign_in_platform_interface/google_sign_in_platform_interface.dart';
68
import 'package:google_sign_in_platform_interface/src/types.dart';
79
import 'package:google_sign_in_platform_interface/src/utils.dart';
8-
import 'package:flutter/services.dart';
9-
import 'package:flutter_test/flutter_test.dart';
1010

1111
const Map<String, String> kUserData = <String, String>{
1212
"email": "john.doe@gmail.com",
@@ -18,6 +18,7 @@ const Map<String, String> kUserData = <String, String>{
1818
const Map<dynamic, dynamic> kTokenData = <String, dynamic>{
1919
'idToken': '123',
2020
'accessToken': '456',
21+
'serverAuthCode': '789',
2122
};
2223

2324
const Map<String, dynamic> kDefaultResponses = <String, dynamic>{

0 commit comments

Comments
 (0)