Create a gist now

Instantly share code, notes, and snippets.

@thephw /fb.js
Last active Dec 16, 2015

What would you like to do?
Extend your facebook authentication token.
function fbExtendAuthentication(accessToken){
var extensionData = {
grant_type: 'fb_exchange_token',
client_id: '', //App ID
client_secret: '', //App Secret, only secure because only admins see this page
fb_exchange_token: accessToken,
};
$.ajax('https://graph.facebook.com/oauth/access_token', {
data: extensionData,
complete: function( jqXHR, status) {
console.log("Facebook extended access response:");
console.log(jqXHR);
if(jqXHR.status == 200){
console.log("data-extended-access-token" + jqXHR.responseText.split('&')[0].split('=')[1]);
console.log("#facebook-data" + jqXHR.responseText.split('&')[0].split('=')[1]);
} else {
console.log("Error retrieving extended-access-token from Facebook API.");
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment