Skip to content

Commit 30b6aa0

Browse files
committed
User info #8
1 parent 253682a commit 30b6aa0

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

android/src/main/java/com/codetrixstudio/capacitor/GoogleAuth/GoogleAuth.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ private void handleSignInResult(Task<GoogleSignInAccount> completedTask) {
7878
JSObject user = new JSObject();
7979
user.put("serverAuthCode", account.getServerAuthCode());
8080
user.put("authentication", authentication);
81+
82+
user.put("displayName", account.getDisplayName());
83+
user.put("email", account.getEmail());
84+
user.put("familyName", account.getFamilyName());
85+
user.put("givenName", account.getGivenName());
86+
user.put("id", account.getId());
87+
user.put("imageUrl", account.getPhotoUrl());
8188

8289
signInCall.success(user);
8390

ios/Plugin/Plugin.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ public class GoogleAuth: CAPPlugin {
8080
"idToken": user.authentication.idToken,
8181
"refreshToken": user.authentication.refreshToken,
8282
],
83-
"serverAuthCode": user.serverAuthCode
83+
"serverAuthCode": user.serverAuthCode,
84+
"email": user.profile.email,
85+
"familyName": user.profile.familyName,
86+
"givenName": user.profile.givenName,
87+
"id": user.userID,
88+
"imageUrl": user.profile.imageURL(withDimension: 100),
89+
"name": user.profile.name
8490
]);
8591
}
8692
}

src/web.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ export class GoogleAuthWeb extends WebPlugin implements GoogleAuthPlugin {
5959

6060
const authResponse = googleUser.getAuthResponse(true);
6161

62+
const profile = googleUser.getBasicProfile();
63+
user.email = profile.getEmail();
64+
user.familyName = profile.getFamilyName();
65+
user.givenName = profile.getGivenName();
66+
user.id = profile.getId();
67+
user.imageUrl = profile.getImageUrl();
68+
user.name = profile.getName();
69+
6270
user.authentication = {
6371
accessToken: authResponse.access_token,
6472
idToken: authResponse.id_token

0 commit comments

Comments
 (0)