Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get email #9

Closed
wonderfly opened this issue Jan 7, 2015 · 4 comments
Closed

Cannot get email #9

wonderfly opened this issue Jan 7, 2015 · 4 comments

Comments

@wonderfly
Copy link
Contributor

From SamDzir...@gmail.com on January 22, 2012 16:35:45

I am using
scopes= [ " https://www.googleapis.com/auth/plus.me ", " https://www.googleapis.com/auth/userinfo.email"]; But somehow
var request = gapi.client.plus.people.get({
'userId': 'me'
});

Does not return an email address. It gets me a lot of info except the email address

Original issue: http://code.google.com/p/google-api-javascript-client/issues/detail?id=7

@wonderfly
Copy link
Contributor Author

From gengkev on February 05, 2012 17:42:58

You need to make a request to /oauth2/v1/userinfo

@wonderfly
Copy link
Contributor Author

From obr...@google.com on May 07, 2012 11:10:20

You should be able to use either API to get the user's email address.

This demo uses oauth2.userinfo.get and plus.people.get to retrieve user information. Both contain the email. https://google-api-javascript-client.googlecode.com/hg/issues/issue7.html For the Google+ API, the response contains an "emails" field which is an array of email objects: https://developers.google.com/+/api/latest/people#resource

Status: Done

@wonderfly
Copy link
Contributor Author

From brettajo...@gmail.com on January 17, 2013 20:10:19

The email is only returned if the user has chosen to make that field publicaly available, which most have not.

@wonderfly
Copy link
Contributor Author

From Jose...@gmail.com on July 07, 2014 14:40:50

once you have the request:
var request = gapi.client.plus.people.get( {'userId' : 'me'} );

call for this:

request.execute(loadProfileCallback);

/**

  • Callback for the asynchronous request to the people.get method. The profile

  • and email are set to global variables. Triggers the user's basic profile

  • to display when called.
    */
    function loadProfileCallback(obj) {
    profile = obj;

    // Filter the emails object to find the user's primary account, which might
    // not always be the first in the array. The filter() method supports IE9+.
    email = obj['emails'].filter(function(v) {
    return v.type === 'account'; // Filter out the primary email
    })[0].value; // get the email from the filtered results, should always be defined.
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant