友だちではない私のアプリの2人のユーザーのために相互の友人を取得する際に問題があります。無効なappsecret_proofがPythonサーバーのAPI引数で提供されました
per all_mutual_friendsパーミッションごとに、私はappsecret_proofパラメータとともにリクエストを行う必要があります。
が、私はこのGET呼び出しを使用してapp_access_token生成:GET /oauth/access_token
?client_id={app-id}
&client_secret={app-secret}
&grant_type=client_credentials
私はトリプルAPP_IDとapp_secretをチェックしましたが、彼らは正しいです。私は、SHA256によってappsecret_proofを生成しました。これは、Javaのapp_secretでapp_access_tokenをハッシュします。私は(クエリパラメータとしてappsecret_proofを送る)共通の友人を要求したとき
は今、それがGraphMethodExceptionと
"Invalid appsecret_proof provided in the API argument"
言って応答します。元のリクエスト(appsecret_proofなし)は、友人であるユーザーのためにうまくいきます。ここにどんなポインタ?ここで
は私がappsecret_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ベースのです。