Skip to content

Commit 8e2f00d

Browse files
authored
[google_sign_in_tizen] Update to google_sign_in 7.2.0 (#1011)
1 parent 843eeda commit 8e2f00d

14 files changed

Lines changed: 852 additions & 278 deletions

packages/google_sign_in/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 0.2.0
2+
3+
* Update `google_sign_in_platform_interface` to 3.1.0.
4+
* Update the Tizen Device Flow implementation for the `google_sign_in` 7.2.0 API.
5+
* Add support for client authorization requests such as `authorizationForScopes`, `authorizeScopes`, and `authorizationHeaders` for Device Flow allowed scopes.
6+
* Update minimum Flutter and Dart versions to 3.29 and 3.7.
7+
18
## 0.1.5
29

310
* Update code format.

packages/google_sign_in/README.md

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ This package is not an _endorsed_ implementation of `google_sign_in`. Therefore,
1010

1111
```yaml
1212
dependencies:
13-
google_sign_in: ^5.4.1
14-
google_sign_in_tizen: ^0.1.5
13+
google_sign_in: ^7.2.0
14+
google_sign_in_tizen: ^0.2.0
1515
```
1616
1717
For detailed usage on how to use `google_sign_in`, see https://pub.dev/packages/google_sign_in#usage.
@@ -28,20 +28,55 @@ You also need to add some additional code to your app to fully integrate `google
2828

2929
### Adding OAuth credentials
3030

31-
Unlike "Authorization Code Grant with PKCE", "Device Flow" requires a [client secret](https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-4:-poll-googles-authorization-server) parameter during Google Sign-In. You must call `GoogleSignInTizen.setCredentials` function with your client's OAuth credentials before calling `google_sign_in`'s API.
31+
Unlike "Authorization Code Grant with PKCE", "Device Flow" requires a [client secret](https://developers.google.com/identity/protocols/oauth2/limited-input-device#step-4:-poll-googles-authorization-server) parameter during Google Sign-In. You must call `GoogleSignInTizen.setCredentials` with your client's OAuth credentials before calling `GoogleSignIn.instance.initialize`.
3232

3333
```dart
34+
import 'package:google_sign_in/google_sign_in.dart';
3435
import 'package:google_sign_in_tizen/google_sign_in_tizen.dart';
3536
36-
GoogleSignInTizen.setCredentials(
37-
clientId: 'YOUR_CLIENT_ID',
38-
clientSecret: 'YOUR_CLIENT_SECRET',
39-
);
37+
Future<void> initializeGoogleSignIn() async {
38+
GoogleSignInTizen.setCredentials(
39+
clientId: 'YOUR_CLIENT_ID',
40+
clientSecret: 'YOUR_CLIENT_SECRET',
41+
);
42+
await GoogleSignIn.instance.initialize(clientId: 'YOUR_CLIENT_ID');
43+
}
44+
```
45+
46+
If you pass `clientId` to `GoogleSignIn.instance.initialize`, it must match the `clientId` passed to `GoogleSignInTizen.setCredentials`.
47+
48+
### Authorizing additional scopes
49+
50+
`GoogleSignInAccount.authorizationClient` can be used to request client authorization tokens on Tizen for scopes allowed by Google OAuth Device Flow. See [Allowed scopes](https://developers.google.com/identity/protocols/oauth2/limited-input-device#allowedscopes) before requesting additional scopes.
51+
52+
Device Flow cannot preselect or force the Google account on the secondary device. If a request is tied to an existing `GoogleSignInAccount` and the user completes the flow with a different account, the request fails with `GoogleSignInExceptionCode.userMismatch`.
53+
54+
```dart
55+
final GoogleSignInClientAuthorization authorization = await user
56+
.authorizationClient
57+
.authorizeScopes(<String>[
58+
'https://www.googleapis.com/auth/youtube.readonly',
59+
]);
60+
```
61+
62+
### Server authorization tokens are not supported
63+
64+
`authorizationClient.authorizeServer(...)` is not supported on Tizen because OAuth 2.0 Device Authorization Grant ([RFC 8628](https://datatracker.ietf.org/doc/html/rfc8628#section-3.5)) does not include a server auth code in its token response — the protocol simply has no such field. Calling it throws `GoogleSignInException` with `GoogleSignInExceptionCode.providerConfigurationError`:
65+
66+
```dart
67+
try {
68+
final GoogleSignInServerAuthorization? serverAuth = await user
69+
.authorizationClient
70+
.authorizeServer(scopes);
71+
} on GoogleSignInException catch (e) {
72+
// e.code == GoogleSignInExceptionCode.providerConfigurationError
73+
// e.description explains why server auth code is unavailable on Tizen.
74+
}
4075
```
4176

4277
:warning: Security concerns
4378

44-
Storing a client secret in code is considered a bad practice as it exposes [security vulnerabilites](https://datatracker.ietf.org/doc/html/rfc8628#section-5.6), you should perform extra steps to protect your client credentials.
79+
Storing a client secret in code is considered a bad practice as it exposes [security vulnerabilities](https://datatracker.ietf.org/doc/html/rfc8628#section-5.6), you should perform extra steps to protect your client credentials.
4580

4681
1. Do not upload credentials to public repositories.
4782

@@ -96,4 +131,4 @@ The `http://tizen.org/privilege/internet` privilege is required to perform netwo
96131

97132
## Supported devices
98133

99-
All devices running Tizen 5.5 or later.
134+
All devices running Tizen 5.5 or later.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:google_sign_in/google_sign_in.dart';
7+
import 'package:google_sign_in_tizen/google_sign_in_tizen.dart';
8+
import 'package:google_sign_in_tizen_example/credentials.dart' as credentials;
9+
import 'package:integration_test/integration_test.dart';
10+
11+
void main() {
12+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
13+
14+
testWidgets('Can initialize the plugin', (WidgetTester tester) async {
15+
GoogleSignInTizen.setCredentials(
16+
clientId: credentials.clientId,
17+
clientSecret: credentials.clientSecret,
18+
);
19+
20+
final GoogleSignIn signIn = GoogleSignIn.instance;
21+
expect(signIn, isNotNull);
22+
23+
await signIn.initialize(clientId: credentials.clientId);
24+
});
25+
}

packages/google_sign_in/example/lib/credentials.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
// on source respositories.
77
//
88
// Developers should fill their own credentials to run the app.
9-
const String cliendId =
9+
const String clientId =
1010
'87599666314-cobrkfg77lk98a6c8l3o2ntn8d9g6s6l.apps.googleusercontent.com';
1111
const String clientSecret = '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';

0 commit comments

Comments
 (0)