我一直在与facebook android sdk合作,并尝试实现以下方案:
String
)传递到我自己的后端服务器我的问题是,从访问令牌中,我只能获取应用程序范围的userId
,而我的后端无法使用它访问来自Facebook服务器的用户信息。我用于处理登录结果的代码非常简单:
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()
}
})
所以,我的问题是如何在后端服务器上获取用户数据?我想如果我也提供我的应用程序ID来请求用户数据,那是有道理的,但是我浏览了Facebook文档,却没有找到任何方式
答案 0 :(得分:1)
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/
时,将div文件加载到div中