Skip to content

Commit e2ed2fa

Browse files
committed
update
1 parent c845f1f commit e2ed2fa

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎v3/js/composingprograms.js‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,15 @@ function signinCallback(authResult) {
100100
'userId': 'me'
101101
});
102102
request.execute(function(resp) {
103-
alert('Retrieved profile for "' + resp.displayName + '"');
103+
// From https://developers.google.com/+/web/people/#retrieve_an_authenticated_users_email_address
104+
105+
// Filter the emails object to find the user's primary account, which might
106+
// not always be the first in the array. The filter() method supports IE9+.
107+
var email = resp['emails'].filter(function(v) {
108+
return v.type === 'account'; // Filter out the primary email
109+
})[0].value; // get the email from the filtered results, should always be defined.
110+
111+
alert('Real name: "' + resp.displayName + '", Email addr: "' + email + '"');
104112
});
105113
});
106114

0 commit comments

Comments
 (0)