Viewing version 1.1.3. Open the latest package page.
google_sign_in_web
1.1.3Flutter plugin for Google Sign-In, a secure authentication system for signing in with a Google account on Android, iOS and Web.
Readme
google_sign_in_web
The web implementation of google_sign_in
Usage
This package is endorsed,
which means you can simply use google_sign_in
normally. This package will be automatically included in your app when you do,
so you do not need to add it to your pubspec.yaml.
However, if you import this package to use any of its APIs directly, you
should add it to your pubspec.yaml as usual.
For example, you need to import this package directly if you plan to use the
web-only Widget renderButton() method.
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="YOUR_GOOGLE_SIGN_IN_OAUTH_CLIENT_ID.apps.googleusercontent.com">
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:
- Going to the Credentials page.
- Clicking "Edit" in the OAuth 2.0 Web application client that you created above.
- Adding the URIs you want to the Authorized JavaScript origins.
For local development, you must add two localhost entries:
http://localhostandhttp://localhost:7357(or any port that is free in your machine)
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
Authentication
This implementation returns false for supportsAuthentication, and will throw
if authenticate is called. This is because the
Google Identity Services (GIS) SDK
only allows signing in using UI provided by the SDK.
On the web, instead of providing custom UI that calls authenticate, you should
display the Widget returned by renderButton (from web_only.dart), and listen
to authenticationEvents to know when the user has signed in.
The GIS SDK does not renew authentication sessions. Once the token expires
(after 3600 seconds), if you need to use the idToken again you must trigger
a new authentication flow. In most cases, you should use the idToken
immediately after authentication, and track sign-in state at the application
level, or via a separate server backend.
Migration from versions before 0.12
See Migrating from Google Sign-In for information about the differences between authentication in the GIS SDK and the SDK used in older versions of this plugin.
Since the GIS SDK does not manage user sessions anymore, apps that relied on this feature might break. If long-lived sessions are required, consider using some user authentication system that supports Google Sign In as a federated Authentication provider, like Firebase Auth.
Authorization
The GIS SDK does not renew authorization sessions. Once the token expires (after 3600 seconds), API requests will begin to fail, and you must re-request user authorization. For example:
401: Missing or invalid access token.403: Expired access token.
See the "Integration considerations > UX separation for authentication and authorization guide" in the official GIS SDK documentation for more information about this.
Migration from versions before 0.12
See Migrate to Google Identity Services for information about the differences between authentication in the GIS SDK and the SDK used in older versions of this plugin.
Changelog
1.1.3
- Restored previously reverted changes to prevent
_initCalledfrom being invoked twice on web. - Fixed
renderButtonbeing stuck on "Getting ready" on web by correcting theFutureBuilderstate check to useConnectionState.done.
1.1.2
- Reverts "Throws a more actionable error when init is called more than once."
1.1.1 (withdrawn)
- Throws a more actionable error when init is called more than once.
- Updates minimum supported SDK version to Flutter 3.35/Dart 3.9.
1.1.0
- Adds support for the
clearAuthorizationTokenmethod. - Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
1.0.0
- BREAKING CHANGE: Switches to implementing version 3.0 of the platform interface package, rather than 2.x, significantly changing the API surface.
- Updates minimum supported SDK version to Flutter 3.27/Dart 3.6.
0.12.4+4
- Asserts that new
forceAccountNameparameter is null (not used in web). - Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
0.12.4+3
- Fixes callback types for
TokenClientConfig.
0.12.4+2
- Adds support for
web: ^1.0.0.
0.12.4+1
- Fixes README.md typo.
0.12.4
- Updates dependencies to
web: ^0.5.0andgoogle_identity_services_web: ^0.3.1.
0.12.3+3
- Updates SDK version to Dart
^3.3.0. Flutter^3.19.0. - Prepares update to package
web: ^0.5.0.
0.12.3+2
- Fixes new lint warnings.
0.12.3+1
- Updates
FlexHtmlElementView(the widget backingrenderButton) to not rely on web engine knowledge (a platform view CSS selector) to operate.
0.12.3
- Migrates to
package:web. - Updates minimum supported SDK version to Flutter 3.16.0/Dart 3.2.0.
0.12.2+1
- Re-publishes
0.12.2with a small fix to the CodeClient initialization.
0.12.2 (withdrawn)
- Adds server auth code retrieval to google_sign_in_web.
- Adds
web_onlylibrary to access web-only methods more easily.
0.12.1
- Enables FedCM on browsers that support this authentication mechanism.
- Uses the expiration timestamps of Credential and Token responses to improve
the accuracy of
isSignedInandcanAccessScopesmethods. - Deprecates
signIn()method.- Users should migrate to
renderButtonandsilentSignIn, as described in the README.
- Users should migrate to
0.12.0+5
- Migrates to
dart:ui_webAPIs. - Updates minimum supported SDK version to Flutter 3.13.0/Dart 3.1.0.
0.12.0+4
- Adds pub topics to package metadata.
- Updates minimum supported SDK version to Flutter 3.7/Dart 2.19.
0.12.0+3
- Fixes null cast error on accounts without picture or name details.
0.12.0+2
- Adds compatibility with
http1.0.
0.12.0+1
- Fixes unawaited_futures violations.
0.12.0
- Authentication:
- Adds web-only
renderButtonmethod and its configuration object, as a new authentication mechanism. - Prepares a
userDataEventsStream, so the Google Sign In Button can propagate authentication changes to the core plugin. - Breaking Change:
signInSilentlynow returns an authenticated (but not authorized) user.
- Adds web-only
- Authorization:
- Implements the new
canAccessScopesmethod. - Ensures that the
requestScopescall doesn't trigger user selection when the current user is known (similar to whatsignIndoes).
- Implements the new
- Updates minimum Flutter version to 3.3.
0.11.0+2
- Clarifies explanation of endorsement in README.
- Aligns Dart and Flutter SDK constraints.
0.11.0+1
- Updates links for the merge of flutter/plugins into flutter/packages.
0.11.0
- Breaking Change: Migrates JS-interop to
package:google_identity_services_web- Uses the new Google Identity Authentication and Authorization JS SDKs. Docs.
- Added "Migrating to v0.11" section to the
README.md.
- Added "Migrating to v0.11" section to the
- Uses the new Google Identity Authentication and Authorization JS SDKs. Docs.
- Updates minimum Flutter version to 3.0.
0.10.2+1
- Updates code for
no_leading_underscores_for_local_identifierslint. - Updates minimum Flutter version to 2.10.
- Renames generated folder to js_interop.
0.10.2
- Migrates to new platform-interface
initWithParamsmethod. - Throws when unsupported
serverClientIdoption is provided.
0.10.1+3
- Updates references to the obsolete master branch.
0.10.1+2
- Minor fixes for new analysis options.
0.10.1+1
- Fixes library_private_types_in_public_api, sort_child_properties_last and use_key_in_widget_constructors lint warnings.
0.10.1
- Updates minimum Flutter version to 2.8.
- Passes
plugin_nameto Google Sign-In'sinitmethod so new applications can continue using this plugin after April 30th 2022. Issue #88084.
0.10.0+5
- Internal code cleanup for stricter analysis options.
0.10.0+4
- Removes dependency on
meta.
0.10.0+3
- Updated URL to the
google_sign_inpackage in README.
0.10.0+2
- Add
implementsto pubspec.
0.10.0+1
- Updated installation instructions in README.
0.10.0
- Migrate to null-safety.
0.9.2+1
- Update Flutter SDK constraint.
0.9.2
- Throw PlatformExceptions from where the GMaps SDK may throw exceptions:
init()andsignIn(). - Add two new JS-interop types to be able to unwrap JS errors in release mode.
- Align the fields of the thrown PlatformExceptions with the mobile version.
- Migrate tests to run with
flutter drive
0.9.1+2
- Update package:e2e reference to use the local version in the flutter/plugins repository.
0.9.1+1
- Remove Android folder from
google_sign_in_web.
0.9.1
- Ensure the web code returns
nullwhen the user is not signed in, instead of anull-objectUser. Fixes issue 52338.
0.9.0
- Add support for methods introduced in
google_sign_in_platform_interface1.1.0.
0.8.4
- Remove all
fakeConstructor$from the generated facade. JS interop classes do not support non-external constructors.
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 https://github.com/flutter/flutter/issues/48527
- 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
Installing
export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'google_sign_in_web:1.1.3'pubspec.yaml
name: google_sign_in_web
description: Flutter plugin for Google Sign-In, a secure authentication system
for signing in with a Google account on Android, iOS and Web.
repository: https://github.com/flutter/packages/tree/main/packages/google_sign_in/google_sign_in_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+google_sign_in%22
version: 1.1.3
environment:
sdk: ^3.9.0
flutter: ">=3.35.0"
flutter:
plugin:
implements: google_sign_in
platforms:
web:
pluginClass: GoogleSignInPlugin
fileName: google_sign_in_web.dart
dependencies:
flutter:
sdk: flutter
flutter_web_plugins:
sdk: flutter
google_identity_services_web: ^0.3.1
google_sign_in_platform_interface: ^3.1.0
http: ">=0.13.0 <2.0.0"
web: ">=0.5.1 <2.0.0"
dev_dependencies:
flutter_test:
sdk: flutter
topics:
- authentication
- google-sign-in
Version history
| Version | Published | Archive | SHA-256 |
|---|---|---|---|
| 0.8.0 | On demand | Download | 446c3590…7d8714 |
| 0.8.1 | On demand | Download | 02a94b41…b6757e |
| 0.8.1+2 | On demand | Download | fb0d1226…c6a1c9 |
| 0.8.2 | On demand | Download | a600ac0b…b4996b |
| 0.8.2+1 | On demand | Download | f77634e8…b05903 |
| 0.8.3 | On demand | Download | 6831bbce…7945df |
| 0.8.3+1 | On demand | Download | fbc83c90…4b69b6 |
| 0.8.3+2 | On demand | Download | 8610b704…d614d7 |
| 0.8.4 | On demand | Download | a71c6020…cc4250 |
| 0.9.0 | On demand | Download | 6bb8e809…9fa86a |
| 0.9.1 | On demand | Download | 04eb0625…734693 |
| 0.9.1+1 | On demand | Download | 0915cae6…00c5ba |
| 0.9.2 | On demand | Download | de62ed46…9f3b9b |
| 0.10.0 | On demand | Download | 2a0d45a4…6150c4 |
| 0.10.0+1 | On demand | Download | 0d21f02f…041484 |
| 0.10.0+2 | On demand | Download | b2aa4a0a…1ac12d |
| 0.10.0+3 | On demand | Download | 1f033801…b632d9 |
| 0.10.0+4 | On demand | Download | 2eaacb0b…aa5032 |
| 0.10.0+5 | On demand | Download | 4c860532…d90901 |
| 0.10.1 | On demand | Download | fd1a6bce…72e3a8 |
| 0.10.1+1 | On demand | Download | df9460c4…2d5e0b |
| 0.10.1+2 | On demand | Download | 9d943fe1…2def3b |
| 0.10.1+3 | On demand | Download | c4dda2f5…9e86aa |
| 0.10.2 | On demand | Download | 5b35c221…263af5 |
| 0.10.2+1 | On demand | Download | 75cc41eb…720b40 |
| 0.11.0 | On demand | Download | a3377878…ca3c49 |
| 0.11.0+1 | On demand | Download | 824b42c0…be9f95 |
| 0.11.0+2 | On demand | Download | 9f883b9b…b0f465 |
| 0.12.0 | On demand | Download | 7e0ec507…0a723f |
| 0.12.0+1 | On demand | Download | 7b154bc8…a12924 |
| 0.12.0+2 | On demand | Download | 69b9ce0e…ea68cc |
| 0.12.0+3 | On demand | Download | c4ef88c4…561c52 |
| 0.12.0+4 | On demand | Download | b48263e4…19ffbe |
| 0.12.0+5 | On demand | Download | 939e9172…279766 |
| 0.12.1 | On demand | Download | 6b08be47…612d8e |
| 0.12.2 | On demand | Download | 0559197e…cc664f |
| 0.12.2+1 | On demand | Download | 794f5494…3015e6 |
| 0.12.3 | On demand | Download | d77bc2a7…ad239d |
| 0.12.3+1 | On demand | Download | 38e6ec2a…8ff549 |
| 0.12.3+2 | On demand | Download | a278ea2d…a69d77 |
| 0.12.3+3 | On demand | Download | f2b3af0b…b35db2 |
| 0.12.4 | On demand | Download | fc0f14ed…e821bd |
| 0.12.4+1 | On demand | Download | d606264c…572228 |
| 0.12.4+2 | On demand | Download | 042805a2…f68055 |
| 0.12.4+3 | On demand | Download | ada595df…c6281b |
| 0.12.4+4 | On demand | Download | 460547be…0e4ded |
| 1.0.0 | On demand | Download | 09ac306b…f7b468 |
| 1.1.0 | On demand | Download | 2fc1f941…75a1da |
| 1.1.1 | On demand | Download | e2658572…38dcb0 |
| 1.1.2 | On demand | Download | dac0676a…db9102 |
| 1.1.3 | Cached · Upstream SHA-256 matched | Download | d473003e…245d14 |
Dependencies
flutter {
"sdk": "flutter"
}
flutter_web_plugins {
"sdk": "flutter"
}
google_identity_services_web "^0.3.1"
google_sign_in_platform_interface "^3.1.0"
http "\u003e=0.13.0 \u003c2.0.0"
web "\u003e=0.5.1 \u003c2.0.0"