Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions packages/google_sign_in/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 0.2.0

* Update `google_sign_in_platform_interface` to 3.1.0.
* Update the Tizen Device Flow implementation for the `google_sign_in` 7.2.0 API.
* Add support for client authorization requests such as `authorizationForScopes`, `authorizeScopes`, and `authorizationHeaders` for Device Flow allowed scopes.
* Update minimum Flutter and Dart versions to 3.29 and 3.7.

## 0.1.5

* Update code format.
Expand Down
53 changes: 44 additions & 9 deletions packages/google_sign_in/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ This package is not an _endorsed_ implementation of `google_sign_in`. Therefore,

```yaml
dependencies:
google_sign_in: ^5.4.1
google_sign_in_tizen: ^0.1.5
google_sign_in: ^7.2.0
google_sign_in_tizen: ^0.2.0
```

For detailed usage on how to use `google_sign_in`, see https://pub.dev/packages/google_sign_in#usage.
Expand All @@ -28,20 +28,55 @@ You also need to add some additional code to your app to fully integrate `google

### Adding OAuth credentials

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.
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`.

```dart
import 'package:google_sign_in/google_sign_in.dart';
import 'package:google_sign_in_tizen/google_sign_in_tizen.dart';

GoogleSignInTizen.setCredentials(
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
);
Future<void> initializeGoogleSignIn() async {
GoogleSignInTizen.setCredentials(
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET',
);
await GoogleSignIn.instance.initialize(clientId: 'YOUR_CLIENT_ID');
}
```

If you pass `clientId` to `GoogleSignIn.instance.initialize`, it must match the `clientId` passed to `GoogleSignInTizen.setCredentials`.

### Authorizing additional scopes

`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.

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`.

```dart
final GoogleSignInClientAuthorization authorization = await user
.authorizationClient
.authorizeScopes(<String>[
'https://www.googleapis.com/auth/youtube.readonly',
]);
```

### Server authorization tokens are not supported

`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`:

```dart
try {
final GoogleSignInServerAuthorization? serverAuth = await user
.authorizationClient
.authorizeServer(scopes);
} on GoogleSignInException catch (e) {
// e.code == GoogleSignInExceptionCode.providerConfigurationError
// e.description explains why server auth code is unavailable on Tizen.
}
```

:warning: Security concerns

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.
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.

1. Do not upload credentials to public repositories.

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

## Supported devices

All devices running Tizen 5.5 or later.
All devices running Tizen 5.5 or later.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter_test/flutter_test.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:google_sign_in_tizen/google_sign_in_tizen.dart';
import 'package:google_sign_in_tizen_example/credentials.dart' as credentials;
import 'package:integration_test/integration_test.dart';

void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

testWidgets('Can initialize the plugin', (WidgetTester tester) async {
GoogleSignInTizen.setCredentials(
clientId: credentials.clientId,
clientSecret: credentials.clientSecret,
);

final GoogleSignIn signIn = GoogleSignIn.instance;
expect(signIn, isNotNull);

await signIn.initialize(clientId: credentials.clientId);
});
}
2 changes: 1 addition & 1 deletion packages/google_sign_in/example/lib/credentials.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
// on source respositories.
//
// Developers should fill their own credentials to run the app.
const String cliendId =
const String clientId =
'87599666314-cobrkfg77lk98a6c8l3o2ntn8d9g6s6l.apps.googleusercontent.com';
const String clientSecret = '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';
Loading
Loading