extension_google_sign_in_as_googleapis_auth 2.0.12 copy "extension_google_sign_in_as_googleapis_auth: ^2.0.12" to clipboard
extension_google_sign_in_as_googleapis_auth: ^2.0.12 copied to clipboard

A bridge package between google_sign_in and googleapis_auth, to create Authenticated Clients from google_sign_in user credentials.

extension_google_sign_in_as_googleapis_auth #

A bridge package between Flutter's google_sign_in plugin and Dart's googleapis package, that is able to create googleapis_auth-like AuthClient instances directly from the GoogleSignIn plugin.

Usage #

This package is implemented as an extension method on top of the GoogleSignIn plugin.

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:

import 'package:extension_google_sign_in_as_googleapis_auth/extension_google_sign_in_as_googleapis_auth.dart';

From that moment on, your GoogleSignIn instance will have an additional Future<AuthClient?> authenticatedClient() method that you can call once your sign in is successful to retrieve an AuthClient.

That object can then be used to create instances of googleapis API clients:

// 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',
);

Example #

This package contains a modified version of Flutter's Google Sign In example app that uses package:googleapis' API clients, instead of raw http requests.

See it here.

The original code (and its license) can be seen here.

Testing #

Run tests with flutter test.

Issues and feedback #

Please file issues to send feedback or report a bug. Thank you!

77
likes
140
pub points
96%
popularity

Publisher

verified publisherflutter.cn

A bridge package between google_sign_in and googleapis_auth, to create Authenticated Clients from google_sign_in user credentials.

Repository (GitHub)
View/report issues
Contributing

Topics

#authentication #google-sign-in

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, google_sign_in, googleapis_auth, http, meta

More

Packages that depend on extension_google_sign_in_as_googleapis_auth