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

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

Open
PoCk3T opened this issue Jul 31, 2014 · 2 comments
Open

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

PoCk3T opened this issue Jul 31, 2014 · 2 comments

Comments

@PoCk3T
Copy link

PoCk3T commented Jul 31, 2014

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 ? 😄

@gorbin
Copy link

gorbin commented Jul 31, 2014

Yes you right, we can get emails only from g+ and facebook.
You can try in my extension of this lib: https://github.com/gorbin/ASNE
Soon I will pull these changes to this lib

I suggest just normolize SocialPerson and add DetailedPersons:
Social person like:
https://github.com/gorbin/ASNE/blob/master/library/src/main/java/com/androidsocialnetworks/lib/persons/SocialPerson.java
and detailed like, for more detailed profile if somebody need, for example birthdays or company name:
https://github.com/gorbin/ASNE/blob/master/library/src/main/java/com/androidsocialnetworks/lib/persons/FacebookPerson.java

@gorbin
Copy link

gorbin commented Aug 4, 2014

add detail and Social person as I wrote...

add email in SocialPerson in pull

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

No branches or pull requests

2 participants