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

How do i get user id and email from the access token ? #15

Open
Dharin-shah opened this issue Aug 12, 2016 · 11 comments
Open

How do i get user id and email from the access token ? #15

Dharin-shah opened this issue Aug 12, 2016 · 11 comments

Comments

@Dharin-shah
Copy link

No description provided.

@edjiang
Copy link
Member

edjiang commented Aug 13, 2016

Hey @Dharin-shah, Simplicity is useful for obtaining an access token when you're using it for authentication with a backend server of your own. In that case, you'd implement the Facebook API / Google API / etc in your backend. If you'd like to make frontend calls to the Facebook / Google APIs, I'd recommend still using the Facebook / Google SDKs, as this is specifically for login.

Here's docs on how to build it into your backend:

https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow#checktoken
https://developers.google.com/identity/protocols/OAuth2UserAgent#validatetoken

@edjiang edjiang closed this as completed Aug 13, 2016
@Dharin-shah
Copy link
Author

Hey @edjiang thanks. I just wanted this lightweight library to do such stuff. Facebook and Google SDK weighs a lot leaving huge redundancy. Just for reference, I think directly calling the facebook api using the access token does the trick
https://graph.facebook.com/me?access_token=<your_access_token>
and for google plus
https://www.googleapis.com/plus/v1/people/me?access_token=<your_access_token>

@edjiang edjiang reopened this Aug 30, 2016
@edjiang
Copy link
Member

edjiang commented Aug 30, 2016

Yeah, I think you're right -- changed my mind on this a bit. Maybe we should be adding this into Simplicity. If you're interested in contributing, I'm probably not going to work on this in the near future -- although I think we should wait until Swift 3 drops and stabilizes to continue work =]

@Dharin-shah
Copy link
Author

Sure. Thanks.

@Marini83
Copy link

Hello Dharin-shah, through the access token you can get name and id fields, but I haven't been able to get the email, have you been able to?

@edjiang
Copy link
Member

edjiang commented Oct 13, 2016

@Marini83 oh! I must have misunderstood your request. Yeah, you need to specifically request the scopes from Facebook.

Check out the docs here: https://github.com/SimplicityMobile/Simplicity#requesting-scopes-for-oauth-providers

@Marini83
Copy link

I stand corrected! I can't believe I didn't think of giving scope first, I thought it was all-inclusive. Thank you @edjiang ! So Dharin-shah could use the scope too correct?

@lfarah
Copy link

lfarah commented Jan 11, 2017

@Dharin-shah's answer was pretty good, but if you want to get the user's Facebook email as well, you need to add an fields=name,email to the url:

https://graph.facebook.com/me?fields=email,name&access_token=[YourAccessToken]

@kakubei
Copy link

kakubei commented Mar 1, 2017

+1 for this feature in Simplicity.

@ghost
Copy link

ghost commented Sep 19, 2017

I've done it here: https://github.com/diegotrevisan/Simplicity.git

@Dharin-shah
Copy link
Author

Why dont you raise a pull request over here, sorry guys, was away for a while, got into a whole other project.

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

5 participants