diff --git a/README.md b/README.md index 2ef456ed0..828262637 100644 --- a/README.md +++ b/README.md @@ -658,6 +658,24 @@ Other user features are:- } ``` +For Google and the example below, we used the library provided at https://pub.dev/packages/google_sign_in + +``` +class OAuthLogin { + final GoogleSignIn _googleSignIn = GoogleSignIn( scopes: ['email', 'https://www.googleapis.com/auth/contacts.readonly'] ); + + sigInGoogle() async { + GoogleSignInAccount account = await _googleSignIn.signIn(); + GoogleSignInAuthentication authentication = await account.authentication; + await ParseUser.loginWith( + 'google', + google(_googleSignIn.currentUser.id, + authentication.accessToken, + authentication.idToken)); + } +} +``` + ## Security for Objects - ParseACL For any object, you can specify which users are allowed to read the object, and which users are allowed to modify an object. To support this type of security, each object has an access control list, implemented by the __ParseACL__ class. diff --git a/lib/src/utils/parse_login_helpers.dart b/lib/src/utils/parse_login_helpers.dart index ae7459de7..483061c95 100644 --- a/lib/src/utils/parse_login_helpers.dart +++ b/lib/src/utils/parse_login_helpers.dart @@ -7,3 +7,11 @@ Map facebook(String token, String id, DateTime expires) { 'expiration_date': expires.toString() }; } + +Map google(String token, String id, String idToken) { + return { + 'access_token': token, + 'id': id, + 'id_token': idToken + }; +}