From Social ID Developers
Jump to: navigation, search



API to automatically get and extend a Facebook token using the Facebook Javascript SDK.

It's necessary to inform your Facebook application id (check in as a parameter in this API. This Facebook application id should be the same configured in the Facebook social app used in your Social Login application (check in If you don't have your social app configured in the Social-ID platform, you should be using the default application, and this API does not work in this case. It's recommended to you create an application on Facebook platform and configure it in the Social-ID platform (see Facebook Application Settings).

This API will check the Facebook Javascript SDK for a logged and if a connected user is found it'll try to extend the short lived token for a long lived one using the Socialid.login.extendCredentials Javascript API


 socialid.login.extendFacebookToken(facebookAppId, callbacks)


facebookAppId required Facebook Application ID. Check your application in this page: Note: use the same social app ID configured in the Social Login.
callbacks optional A Javascript object containing handlers for the following events: onConnected, onUnauthorized and onLoggedOut.

API Response

This API performs various callbacks.

The following callbacks passed as parameter to this API will be performed:

  • onConnected(accessToken, response): the user is logged into Facebook and has authorized the social application. "accessToken" is the short lived access token provided by Facebook and "response" is the Socialid.login.extendCredentials API response which contains the long lived access token.
  • onUnauthorized(): the user is logged into Facebook, but has not authorized the social application.
  • onLoggedOut(): the user is not logged into Facebook.


Automatically extends a short lived access token provided by Facebook Javascript SDK:

 var appId = 1, fbAppId = '12345';
 socialid.login.extendFacebookToken(fbAppId, {
    onConnected: onConnected,
    onUnauthorized: onUnauthorized,
    onLoggedOut: onLoggedOut
 /* Facebook Login Callbacks */
 function onConnected(accessToken, response) {
    alert("You are connected to Facebook.");
    alert("Short lived access token: " + accessToken);
    alert("Long lived access token: " +;
 function onUnauthorized() {
    alert("You are logged in to Facebook but have not authorized the application.");
 function onLoggedOut() {
    alert("You are not logged in to Facebook.");
Personal tools