I am searching for something similar to what Facebook::setAccessToken($access_token)
does in the PHP SDK ; that is, set the access token used for subsequent requests (having retrieved it by other means).
In the Javascript one, I can only find the getter (FB.getAccessToken
). I imagine this has been made on purpose to avoid using the access token client-side, but what are the risks if only the user related to the access token can see it ?
I could embed it as a parameter for each query, but this is impossible for XFBML as far as I know.
Any idea ?
The Tokens SDK provides you with the fastest and easiest way to create tokens that represent any kind of asset on your network. This asset can be anything you want it to be - conceptual, physical, valuable or not.
This token verifies your identity. It can authenticate who you are, and authorize various resources you have access to. If you by any chance don't know any of these keywords, be patient, I'll explain everything below. This will be a step by step tutorial of how to add token based authentication to an existing REST API.
There is nothing built-in in the SDK.
If you really needed it, you could hack it this way:
FB.provide('', {
'setAccessToken': function(a) {
this._authResponse = { 'accessToken': a };
}
});
// Usage
FB.setAccessToken('my_access_token');
But if you do this, Facebook will log to their server that you use a "deprecated" function of their SDK and send you a warning message. Better pass it to the requests directly (this is what I ended up to).
That does not work for XFBML though (you will have to issue FQL queries yourself and populate your own markup).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With