I am trying to use Facebook to authenticate users. It works fine except for Ajax calls. In most cases, it just sends the old token, and I get:
{"error":{"message":"This authorization code has been used.","type":"OAuthException","code":100}}
So what I tried to do is wrap each ajax call with
FB.getLoginStatus(function(response) { if (response.status === 'connected') { return fn(); ...
this did not work, so I added: true as the getLoginStatus parameter to prevent caching:
FB.getLoginStatus(function(response) { if (response.status === 'connected') { console.log('connected'); fn(); } else if (response.status === 'not_authorized') { console.log('not_authorized); } else { console.log('not_logged_in'); } },true);
Excellent! It is also terribly slow. Am I doing something wrong? Can I get a new token after each action, so I don’t have to wait until the next?
Thanks w
source share