Skip to content

Get user's email from Facebook & Google+ #29

@PoCk3T

Description

@PoCk3T

Hello everyone,

Again, as I was already telling Anton by email, congrats for the work done here, it's brilliant and really make our life easier for social networking implementation.

I'm writing here because I was wondering how to retrieve user's email.
I need it in the "login" feature of Social Networks, and only for Google+ & Facebook, and I was quite surprised it was not possible to access user's email from SocialPerson.email yet because I know Facebook Android SDK & Google+ Android API allow this 😃

So based on Anton suggestion, here's my issue ticket regarding this.

Also, here's how that could be done & implemented in Android Social Networks :
-- For Facebook

Line 166 of "FacebookSocialPerson.java" (in the "impl" folder of Social Networks) '''request.executeAsync();'''

Just before we could add
'''Bundle params = request.getParameters();
request.putString("fields", "email,name,<OTHER NECESSARY ?>");
request.setParameters(params);'''

Facebook's default approved item for an application to connect to FB's APIs include email, by default, again, so might be good for Facebook scopes already.

-- For Google+
Line 100 of "GooglePlusSocialNetwork.java" (in the "impl" folder of Social Networks)
'''Person person = mPlusClient.getCurrentPerson();'''

We could simply add after that :
socialPerson.email = mPlusClient.getAccountName();
For me, "getAccountName" possibly returns the email of the user (not always the case, but worth try it 👯 )

Maybe the scopes need to be extended compared to what Social Networks is asking. Here is what I used to ask as 'scopes' for Google+ sign in 👍

'''mPlusClient = new PlusClient.Builder(mContext, this, this).setScopes(Plus.SCOPE_PLUS_LOGIN.en(), Plus.SCOPE_PLUS_PROFILE.en()).build();'''

What do you think guys ? 😄

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions