Reputation: 870
I've been working with facebook android sdk and trying to implement the following scheme:
String
) to my own backend serverMy problem is that from access token I can only retreive app-scoped userId
, which can't be used by my backend to access the user information from facebook server. The code I use for handling login result is pretty simple:
facebookButton.registerCallback(callbackManager, object : FacebookCallback<LoginResult> {
override fun onSuccess(result: LoginResult?) {
//Pass token to my backend
loginByToken(result?.accessToken?.token!!, FACEBOOK_PROVIDER)
}
override fun onCancel() {
Toast.makeText(context, "Facebook login cancelled", Toast.LENGTH_SHORT).show()
}
override fun onError(error: FacebookException?) {
Toast.makeText(context, error.toString(), Toast.LENGTH_SHORT).show()
}
})
I'm also using the following autorization scheme:
So, my question is how do I get the user data on my backend server? I guess it'd make sense if I also provide my app id for request user data, but I went through facebook documentation, and haven't found any way of doing so
Upvotes: 0
Views: 62
Reputation: 74014
The only way to get data of the user is to use his access token. Since you pass that token to your server anyway, it should be no problem to use it:
/me?fields=id,name,...&access_token=xxx
For identifying returning users, you only need the app scoped id though. If you want to identify users across different Apps: https://developers.facebook.com/docs/apps/for-business/
Upvotes: 1