diff --git a/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md b/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md index 682ad3a146f..4d98d664590 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md +++ b/packages/extension_google_sign_in_as_googleapis_auth/CHANGELOG.md @@ -1,6 +1,7 @@ -## NEXT +## 2.0.12 * Updates minimum supported SDK version to Flutter 3.10/Dart 3.0. +* Updates README to improve example of using google_sign_in plugin with the `googleapis` package. ## 2.0.11 diff --git a/packages/extension_google_sign_in_as_googleapis_auth/README.md b/packages/extension_google_sign_in_as_googleapis_auth/README.md index 2f8a376c47d..ddc66711d40 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/README.md +++ b/packages/extension_google_sign_in_as_googleapis_auth/README.md @@ -1,6 +1,6 @@ # extension_google_sign_in_as_googleapis_auth -A bridge package between Flutter's [`google_sign_in` plugin](https://pub.dev/packages/google_sign_in) and Dart's [`googleapis` package](https://pub.dev/packages/googleapis), that is able to create [`googleapis_auth`-like `AuthClient` instances](https://pub.dev/documentation/googleapis_auth/latest/googleapis_auth.auth/AuthClient-class.html) directly from the `GoogleSignIn` plugin. +A bridge package between Flutter's [`google_sign_in` plugin](https://pub.dev/packages/google_sign_in) and Dart's [`googleapis` package](https://pub.dev/packages/googleapis), that is able to create [`googleapis_auth`-like `AuthClient` instances](https://pub.dev/documentation/googleapis_auth/latest/googleapis_auth/AuthClient-class.html) directly from the `GoogleSignIn` plugin. ## Usage @@ -8,6 +8,7 @@ This package is implemented as an [extension method](https://dart.dev/guides/lan In order to use it, you need to add a `dependency` to your `pubspec.yaml`. Then, wherever you're importing `package:google_sign_in/google_sign_in.dart`, add the following: + ```dart import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; ``` @@ -16,9 +17,18 @@ From that moment on, your `GoogleSignIn` instance will have an additional `Futur That object can then be used to create instances of `googleapis` API clients: + ```dart -final peopleApi = PeopleApi((await _googleSignIn.authenticatedClient())!); -final response = await peopleApi.people.connections.list( +// Retrieve an [auth.AuthClient] from the current [GoogleSignIn] instance. +final auth.AuthClient? client = await _googleSignIn.authenticatedClient(); + +assert(client != null, 'Authenticated client missing!'); + +// Prepare a People Service authenticated client. +final PeopleServiceApi peopleApi = PeopleServiceApi(client!); +// Retrieve a list of the `names` of my `connections` +final ListConnectionsResponse response = + await peopleApi.people.connections.list( 'people/me', personFields: 'names', ); diff --git a/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart b/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart index 8e982ace225..369135371ed 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart +++ b/packages/extension_google_sign_in_as_googleapis_auth/example/lib/main.dart @@ -4,7 +4,9 @@ import 'dart:async'; +// #docregion Import import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart'; +// #enddocregion Import import 'package:flutter/material.dart'; import 'package:google_sign_in/google_sign_in.dart'; import 'package:googleapis/people/v1.dart'; @@ -58,6 +60,7 @@ class SignInDemoState extends State { _contactText = 'Loading contact info...'; }); +// #docregion CreateAPIClient // Retrieve an [auth.AuthClient] from the current [GoogleSignIn] instance. final auth.AuthClient? client = await _googleSignIn.authenticatedClient(); @@ -71,6 +74,7 @@ class SignInDemoState extends State { 'people/me', personFields: 'names', ); + // #enddocregion CreateAPIClient final String? firstNamedContactName = _pickFirstNamedContact(response.connections); diff --git a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml index 4d5e1a06b3f..3adbd967744 100644 --- a/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml +++ b/packages/extension_google_sign_in_as_googleapis_auth/pubspec.yaml @@ -8,7 +8,7 @@ name: extension_google_sign_in_as_googleapis_auth description: A bridge package between google_sign_in and googleapis_auth, to create Authenticated Clients from google_sign_in user credentials. repository: https://github.com/flutter/packages/tree/main/packages/extension_google_sign_in_as_googleapis_auth issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+extension_google_sign_in_as_googleapis_auth%22 -version: 2.0.11 +version: 2.0.12 environment: sdk: ">=3.0.0 <4.0.0" diff --git a/script/configs/temp_exclude_excerpt.yaml b/script/configs/temp_exclude_excerpt.yaml index 7d56d427edb..fa4bdeed370 100644 --- a/script/configs/temp_exclude_excerpt.yaml +++ b/script/configs/temp_exclude_excerpt.yaml @@ -6,7 +6,6 @@ # TODO(stuartmorgan): Remove everything from this list. See # https://github.com/flutter/flutter/issues/102679 - espresso -- extension_google_sign_in_as_googleapis_auth - go_router_builder - image_picker_for_web - in_app_purchase/in_app_purchase