I'm using Facebook's Javascript SDK, but it's returning the error:
API calls from the server require an appsecret_proof argument
I'm familiar with why it would return this error server-side through PHP - but this is client-side javascript, and can't see why it would ever return this error.
Stripped-down code as follows:
window.fbAsyncInit = function () {
FB.init({
appId: [my app id],
xfbml: true,
version: 'v2.2'
});
};
(function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {
return;
}
js = d.createElement(s);
js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
FB.login(function (res) {
if (res.authResponse) {
if (res.authResponse.grantedScopes.indexOf("manage_pages") >= 0) {
FB.api('/me/accounts', function (res) {
if (res && !res.error) {
/*
* Should show pages available for
* the facebook user to manage ...
* (code removed)
*/
}
else {
/*
* Instead, shows 'API calls from the
* server require an appsecret_proof
* argument" error here
*/
console.log("Error /me/accounts: " + JSON.stringify(res.error));
}
});
}
}
});
This works fine if I turn off the 'App Secret Proof for Server API calls' in the Facebook App settings, but for security reasons I want this on.
This shouldn't fail through a javascript call - it's a client-side API call, not a server API call that the error message describes it as.
Is this a bug with Facebook, or something I'm missing somewhere?