Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java python服务器上的API参数中提供的appsecret\u证明无效_Java_Facebook_Facebook Graph Api - Fatal编程技术网

Java python服务器上的API参数中提供的appsecret\u证明无效

Java python服务器上的API参数中提供的appsecret\u证明无效,java,facebook,facebook-graph-api,Java,Facebook,Facebook Graph Api,我很难为我应用程序的两个非好友用户获取共同好友 根据all_mutual_friends权限,我需要提出请求以及appsecret_proof参数 我使用此GET调用生成了app_access_令牌: GET /oauth/access_token ?client_id={app-id} &client_secret={app-secret} &grant_type=client_credentials 我已经三次检查了app_id和app_secret,它们是正确的。我用Ja

我很难为我应用程序的两个非好友用户获取共同好友

根据all_mutual_friends权限,我需要提出请求以及appsecret_proof参数

我使用此GET调用生成了app_access_令牌:

GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
我已经三次检查了app_id和app_secret,它们是正确的。我用Java中的app_secret对app_access_令牌进行哈希处理,生成了appsecret_证明

现在,当我请求共同的朋友(发送appsecret_证明作为查询参数)时,它的响应是

"Invalid appsecret_proof provided in the API argument" 
用一种图形方法来感知。原始请求(没有appsecret\u证明)对于朋友用户来说效果良好。这里有什么指示吗

下面是我用来生成appsecret\u-proof的java代码:

public static String hashMac(String text, String secretKey)
throws SignatureException {

try {
    Key sk = new SecretKeySpec(secretKey.getBytes(), HASH_ALGORITHM);
    Mac mac = Mac.getInstance(sk.getAlgorithm());
    mac.init(sk);
    final byte[] hmac = mac.doFinal(text.getBytes());
    return toHexString(hmac);
} catch (NoSuchAlgorithmException e1) {// throw an exception or pick a different encryption method
    throw new SignatureException(
    "error building signature, no such algorithm in device "
    + HASH_ALGORITHM);
} catch (InvalidKeyException e) {
    throw new SignatureException(
   "error building signature, invalid key " + HASH_ALGORITHM);
}
}

private static final String HASH_ALGORITHM = "HmacSHA256";

public static String toHexString(byte[] bytes) { 
   StringBuilder sb = new StringBuilder(bytes.length * 2); 

   Formatter formatter = new Formatter(sb); 
   for (byte b : bytes) { 
     formatter.format("%02x", b); 
   } 

return sb.toString(); 
}

我的服务器是基于python的。

我能够找到共同的朋友。我使用app_access_令牌生成appsecret_证明,但需要使用会话用户的access_令牌生成appsecret_证明。显然,Facebook没有对此进行记录