I am using Facebook Login for Android. It works. I can log in through the emulator. However, I need to send back information to my Rails Rest API. Upon facebook callback success, I want to send back the access token, the provider (“facebook”), the uid, facebook user name, facebook user email and the facebook image icon.
loginButton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
@Override
public void onSuccess(LoginResult loginResult) {
Log.i("AUTHENTICATION TOKEN", String.valueOf(loginResult.getAccessToken()));
}
Logcat shows the following:
I/AUTHENTICATIONÂ TOKEN: {AccessToken token:ACCESS_TOKEN_REMOVED permissions:[public_profile, contact_email, email]}
How do I get the information I need onSuccess
?
2
Answers
try this
Once you have the access token obtained using
LoginResult.getAccessToken()
,You need to call the Facebook Graph api using the access token received. From the SDK Docs,
The JSONObject
object
will contain the required user information provided the user has granted all the necessary permissions to your applicationThe list of fields available for user can be seen here