来自服务器的API调用需要appsecret_proof参数

dwb*_*ito 14 android facebook facebook-graph-api android-facebook

我无法使用Android Facebook SDK发出API请求,甚至无法从登录回调中获取用户 - 它始终返回null.

特别是,使用newMeRequest,我收到以下错误消息:

{ "error": {
 "message": "API calls from the server require an appsecret_proof argument", 
 "type": "GraphMethodException", 
 "code": 100   } }
Run Code Online (Sandbox Code Playgroud)

实际上,它似乎很明显,因为在Facebook应用程序选项中将标志设置为true.但是,我知道移动sdks可以在没有秘密的情况下发出API请求.但是,如果我尝试使用currentSessionFacebook Graph API调试器中的访问令牌,则响应将与上面相同.

我不知道这是否与新的Android Facebook SDK有关,但我的代码与示例中的代码基本相同.登录很顺利,我得到会话令牌,但我不能发出任何API请求...

loginButton.setUserInfoChangedCallback(new LoginButton.UserInfoChangedCallback() {
    @Override
    public void onUserInfoFetched(GraphUser user) {
        graphUser = user;
    }
});


Request.newMeRequest(currentSession, new Request.GraphUserCallback() {
    @Override
    public void onCompleted(GraphUser user, Response response) {
    }
    }
}).executeAsync();
Run Code Online (Sandbox Code Playgroud)

dwb*_*ito 31

我是能够把它的工作的唯一办法,是通过设置NoApp Secret proof for API calls在Facebook的应用程序的高级设置.

但是,这是一个修复,而不是解决,因为我无法在选项设置中执行请求Yes(在iOS facebook sdk中可能).


小智 11

你需要在你的请求中添加一个参数"appsecret_proof",其中包含accessToken和appSecret的'sha256'哈希值

https://developers.facebook.com/docs/graph-api/securing-requests


Don*_*nal 6

您需要Require App Secret在 facebook 应用程序提前设置中禁用。

  • 这是安全的吗?禁用该选项会带来哪些安全风险? (2认同)