google_sign_in_web 0.8.3+2

  • Readme
  • Changelog
  • Installing
  • 89

google_sign_in_web #

The web implementation of google_sign_in

Usage #

Import the package #

This package is the endorsed implementation of google_sign_in for the web platform since version 4.1.0, so it gets automatically added to your dependencies by depending on google_sign_in: ^4.1.0.

No modifications to your pubspec.yaml should be required in a recent enough version of Flutter (>=1.12.13+hotfix.4):

  google_sign_in: ^4.1.0

Web integration #

First, go through the instructions here to create your Google Sign-In OAuth client ID.

On your web/index.html file, add the following meta tag, somewhere in the head of the document:

<meta name="google-signin-client_id" content="">

For this client to work correctly, the last step is to configure the Authorized JavaScript origins, which identify the domains from which your application can send API requests. When in local development, this is normally localhost and some port.

You can do this by:

  1. Going to the Credentials page.
  2. Clicking "Edit" in the OAuth 2.0 Web application client that you created above.
  3. Adding the URIs you want to the Authorized JavaScript origins.

For local development, may add a localhost entry, for example: http://localhost:7357

Starting flutter in http://localhost:7357

Normally flutter run starts in a random port. In the case where you need to deal with authentication like the above, that's not the most appropriate behavior.

You can tell flutter run to listen for requests in a specific host and port with the following:

flutter run -d chrome --web-hostname localhost --web-port 7357

Other APIs #

Read the rest of the instructions if you need to add extra APIs (like Google People API).

Using 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 = GoogleSignIn(
  scopes: [

Full list of available scopes.

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

Future<void> _handleSignIn() async {
  try {
    await _googleSignIn.signIn();
  } catch (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.

Contributions and Testing #

Tests are a crucial to contributions to this package. All new contributions should be reasonably tested.

In order to run tests in this package, do:

flutter test --platform chrome -j1

Contributions to this package are welcome. Read the Contributing to Flutter Plugins guide to get started.

Issues and feedback #

Please file issues to send feedback or report a bug.

Thank you!

0.8.3+2 #

  • Make the pedantic dev_dependency explicit.

0.8.3+1 #

  • Updated documentation with more instructions about Google Sign In web setup.

0.8.3 #

  • Fix initialization error that causes
  • Throw a PlatformException when there's an initialization problem (like wrong server-side config).
  • Throw a StateError when checking .initialized before calling .init()
  • Update setup instructions in the README.

0.8.2+1 #

  • Add a non-op Android implementation to avoid a flaky Gradle issue.

0.8.2 #

  • Require Flutter SDK 1.12.13+hotfix.4 or greater.

0.8.1+2 #

  • Remove the deprecated author: field from pubspec.yaml
  • Require Flutter SDK 1.10.0 or greater.

0.8.1+1 #

  • Add missing documentation.

0.8.1 #

  • Add podspec to enable compilation on iOS.

0.8.0 #

  • Flutter for web initial release

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  google_sign_in_web: ^0.8.3+2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:google_sign_in_web/google_sign_in_web.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/src/generated/gapiauth2.dart. (-25 points)

Analysis of lib/src/generated/gapiauth2.dart reported 98 hints, including:

line 53 col 16: The declaration '_GoogleAuth' isn't referenced.

line 104 col 23: Name non-constant identifiers using lowerCamelCase.

line 105 col 16: Name non-constant identifiers using lowerCamelCase.

line 110 col 21: Name non-constant identifiers using lowerCamelCase.

line 111 col 16: Name non-constant identifiers using lowerCamelCase.

Fix lib/src/generated/gapi.dart. (-10.44 points)

Analysis of lib/src/generated/gapi.dart reported 22 hints, including:

line 22 col 23: Name non-constant identifiers using lowerCamelCase.

line 23 col 16: Name non-constant identifiers using lowerCamelCase.

line 30 col 23: Name non-constant identifiers using lowerCamelCase.

line 31 col 16: Name non-constant identifiers using lowerCamelCase.

line 32 col 49: Name non-constant identifiers using lowerCamelCase.

Fix lib/google_sign_in_web.dart. (-0.50 points)

Analysis of lib/google_sign_in_web.dart reported 1 hint:

line 125 col 9: 'await' applied to 'GoogleUser', which is not a 'Future'.

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and google_sign_in_web.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
flutter_web_plugins 0.0.0
google_sign_in_platform_interface ^1.0.0 1.0.4
js ^0.6.1 0.6.1+1
meta ^1.1.7 1.1.8
Transitive dependencies
collection 1.14.11 1.14.12
matcher 0.12.6
path 1.6.4
quiver 2.1.2+1
sky_engine 0.0.99
stack_trace 1.9.3
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
google_sign_in ^4.0.14
pedantic ^1.8.0