Skip to content

[extension_google_sign_in_as_googleapis_auth] Adopt code excerpts in … #5496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:

<?code-excerpt "example/lib/readme_excerpts.dart (Import)"?>
```dart
import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart';
```
Expand All @@ -16,9 +17,12 @@ 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:

<?code-excerpt "example/lib/readme_excerpts.dart (CreateAPIClient)"?>
```dart
final peopleApi = PeopleApi((await _googleSignIn.authenticatedClient())!);
final response = await peopleApi.people.connections.list(
final PeopleServiceApi peopleApi =
PeopleServiceApi((await _googleSignIn.authenticatedClient())!);
final ListConnectionsResponse response =
await peopleApi.people.connections.list(
'people/me',
personFields: 'names',
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// 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.

// #docregion Import
import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart';
// #enddocregion Import
import 'package:google_sign_in/google_sign_in.dart';
import 'package:googleapis/people/v1.dart';

final GoogleSignIn _googleSignIn = GoogleSignIn();

/// Demonstrates using GoogleSignIn authenticated client to use `googleapis` API clients
Future<ListConnectionsResponse> createAPIClient() async {
// #docregion CreateAPIClient
final PeopleServiceApi peopleApi =
PeopleServiceApi((await _googleSignIn.authenticatedClient())!);
final ListConnectionsResponse response =
await peopleApi.people.connections.list(
'people/me',
personFields: 'names',
);
// #enddocregion CreateAPIClient

return response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion script/configs/temp_exclude_excerpt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# https://github.com/flutter/flutter/issues/102679
- css_colors
- espresso
- extension_google_sign_in_as_googleapis_auth
- flutter_image
- go_router_builder
- google_sign_in/google_sign_in
Expand Down