google_sign_in 3.0.2 copy "google_sign_in: ^3.0.2" to clipboard
google_sign_in: ^3.0.2 copied to clipboard

outdated

Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android and iOS.

google_sign_in #

pub package

A Flutter plugin for Google Sign In.

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

Android integration #

To access Google Sign-In, you'll need to make sure to register your application.

You don't need to include the google-services.json file in your app unless you are using Google services that require it. You do need to enable the OAuth APIs that you want, using the Google Cloud Platform API manager. For example, if you want to mimic the behavior of the Google Sign-In sample app, you'll need to enable the Google People API.

iOS integration #

  1. First register your application.
  2. Open Xcode. You'll have to paste this into Xcode to properly register GoogleServices-Info.plist.
  3. Select GoogleServices-Info.plist from the file manager and drag that file into the Runner directory, [my_project]/ios/Runner/GoogleServices-Info.plist.
  4. A dialog will show up and ask you to select the targets, select the Runner target.
  5. Then add the CFBundleURLTypes attributes below into the [my_project]/ios/Runner/Info.plist file.
<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
	<dict>
		<key>CFBundleTypeRole</key>
		<string>Editor</string>
		<key>CFBundleURLSchemes</key>
		<array>
			<!-- TODO Replace this value: -->
			<!-- Copied from GoogleServices-Info.plist key REVERSE_CLIENT_ID -->
			<string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
		</array>
	</dict>
</array>
<!-- End of the Google Sign-in Section -->

Usage #

Import the package #

To use this plugin, follow the plugin installation instructions.

Use the plugin #

Add the following import to your Dart code:

import 'package:google_sign_in/google_sign_in.dart';

Initialize GoogleSignIn with the scopes you want:

GoogleSignIn _googleSignIn = new GoogleSignIn(
  scopes: [
    'email',
    'https://www.googleapis.com/auth/contacts.readonly',
  ],
);

You can now use the GoogleSignIn class to authenticate in your Dart code, e.g.

Future<Null> _handleSignIn() async {
  try {
    await _googleSignIn.signIn();
  } catch (error) {
    print(error);
  }
}

Example #

Find the example wiring in the Google sign-in example application.

API details #

See the google_sign_in.dart for more API details.

Issues and feedback #

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

2842
likes
0
pub points
100%
popularity

Publisher

verified publisherflutter.cn

Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android and iOS.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on google_sign_in