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

Commit

Permalink
[force-code-for-refresh-token-platform-interface] Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
fbcouch committed Apr 27, 2022
1 parent 1e662ad commit c777100
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 34 deletions.
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>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## 2.1.3

* Add `SignInInitParameters` class to hold all sign in params, including the new `forceCodeForRefreshToken`.
* Adds `SignInInitParameters` class to hold all sign in params, including the new `forceCodeForRefreshToken`.

## 2.1.2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,7 @@ abstract class GoogleSignInPlatform {
String? hostedDomain,
String? clientId,
}) async {
await initWithParams(
SignInInitParameters(
scopes: scopes,
signInOption: signInOption,
hostedDomain: hostedDomain,
clientId: clientId,
),
);
throw UnimplementedError('init() has not been implemented.');
}

/// Initializes the plugin. You must call this method before calling other
Expand All @@ -106,7 +99,12 @@ abstract class GoogleSignInPlatform {
///
/// * [SignInInitParameters]
Future<void> initWithParams(SignInInitParameters params) async {
throw UnimplementedError('initWithParams() has not been implemented');
await init(
scopes: params.scopes,
signInOption: params.signInOption,
hostedDomain: params.hostedDomain,
clientId: params.clientId,
);
}

/// Attempts to reuse pre-existing credentials to sign in again, without user interaction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/widgets.dart';
import 'package:quiver/core.dart';

/// Default configuration options to use when signing in.
Expand All @@ -24,26 +25,12 @@ enum SignInOption {

/// The parameters to use when initializing the sign in process.
///
/// 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 list of [scopes] are OAuth scope codes to request when signing in.
/// These scope codes will determine the level of data access that is granted
/// to your application by the user. The full list of available scopes can be
/// found here: <https://developers.google.com/identity/protocols/googlescopes>
///
/// The [signInOption] determines the user experience. [SigninOption.games] is
/// only supported on Android.
///
/// The [forceCodeForRefreshToken] is used on Android to ensure the authentication
/// code can be exchanged for a refresh token after the first request.
///
/// See:
/// https://developers.google.com/identity/sign-in/web/reference#gapiauth2initparams
@immutable
class SignInInitParameters {
/// The parameters to use when initializing the sign in process.
SignInInitParameters({
const SignInInitParameters({
this.scopes = const <String>[],
this.signInOption = SignInOption.standard,
this.hostedDomain,
Expand All @@ -52,23 +39,24 @@ class SignInInitParameters {
});

/// The list of OAuth scope codes to request when signing in.
List<String> scopes;
final List<String> scopes;

/// The user experience to use when signing in. [SignInOption.games] is
/// only supported on Android.
SignInOption signInOption;
final SignInOption signInOption;

/// Restricted sign in to accounts of the user in the specified domain.
/// Restricts sign in to accounts of the user in the specified domain.
/// By default, the list of accounts will not be restricted.
String? hostedDomain;
final String? hostedDomain;

/// The client ID to use when signing in.
String? clientId;
final String? clientId;

/// Ensure the authorization code can be exchanged for an access token.
/// If true, ensures the authorization code can be exchanged for an access
/// token.
///
/// This is only used on Android.
bool forceCodeForRefreshToken;
final bool forceCodeForRefreshToken;
}

/// Holds information about the signed in user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void main() {
});

test('initWithParams passes through arguments to the channel', () async {
await googleSignIn.initWithParams(SignInInitParameters(
await googleSignIn.initWithParams(const SignInInitParameters(
hostedDomain: 'example.com',
scopes: <String>['two', 'scopes'],
signInOption: SignInOption.games,
Expand Down

0 comments on commit c777100

Please sign in to comment.