Skip to content

Commit 80e486c

Browse files
authored
Add google login helper (#387)
- Update README to show how to get google login attributes for parse
1 parent 78bb537 commit 80e486c

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,24 @@ Other user features are:-
658658
}
659659
```
660660

661+
For Google and the example below, we used the library provided at https://pub.dev/packages/google_sign_in
662+
663+
```
664+
class OAuthLogin {
665+
final GoogleSignIn _googleSignIn = GoogleSignIn( scopes: ['email', 'https://www.googleapis.com/auth/contacts.readonly'] );
666+
667+
sigInGoogle() async {
668+
GoogleSignInAccount account = await _googleSignIn.signIn();
669+
GoogleSignInAuthentication authentication = await account.authentication;
670+
await ParseUser.loginWith(
671+
'google',
672+
google(_googleSignIn.currentUser.id,
673+
authentication.accessToken,
674+
authentication.idToken));
675+
}
676+
}
677+
```
678+
661679
## Security for Objects - ParseACL
662680
For any object, you can specify which users are allowed to read the object, and which users are allowed to modify an object.
663681
To support this type of security, each object has an access control list, implemented by the __ParseACL__ class.

lib/src/utils/parse_login_helpers.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ Map<String, dynamic> facebook(String token, String id, DateTime expires) {
77
'expiration_date': expires.toString()
88
};
99
}
10+
11+
Map<String, dynamic> google(String token, String id, String idToken) {
12+
return <String, dynamic>{
13+
'access_token': token,
14+
'id': id,
15+
'id_token': idToken
16+
};
17+
}

0 commit comments

Comments
 (0)