This article describes the various endpoints related to Unlink User API. This API is used to unlink a user from the currently signed social network and it also revokes app permissions from the respective social network.


The API Call

ssmi_unlink_user(email)

Description: This API is used to unlink a user from the currently signed social network and it also revokes app permissions from the respective social network.


Request Parameter: email

Description: This is the email address of the user to be unlinked.

 


Call Back Functions

ssmi_user_unlink_success(response)


This is the success callback method of the API call. The response object is passed as argument.


The fields of the response object are as follows:


Name Description
is_unlinked

True if user exists for unlink.  

False if user does not exist for unlink.

is_permissions_revoked

True if app permissions are revoked and false if not.  

This field will always be false if is_unlinked is false.

 

ssmi_user_unlink_failure(response)


This is the failure callback method of the API call. The response objects is passed as argument.


The fields of the response object are:


Name Description
error

Set to true when there is a failure in unlinking user.  

Also true when no email is passed.  

reason

Reason for failure.  

  • Email address missing
  • Processing Eroor


Example


Below is the sample code snippet. The snippet contains placeholder code for login handling.


//Code snippet for sample implementation:

ss_mi.ssmi_unlink_user('ssuser@gmail.com') //calling API

var ssmi_user_unlink_success = function(response){

   if(response.is_unlinked == true){

          is_revoked = response.is_permissions_revoked;

 

        /*Handle code to alert user saying that he his unlink from current network

         and he may log into another network

        */

    }

    else{

        /* Notify user that give email address does not exist in db so can not unlink

         */

    }

}

var ssmi_user_unlink_failure = function(response){

 if(response.error == true){

  //print reason for error

   console.log(response.reason);

                 // take necessary actions

 }

}


Below are the scenarios and the corresponding API response.


1) User exists and if API call succeeds and user is unlinked successfully:


Call: ss_mi.ssmi_unlink_user('abc@gmail.com')  

Response: Object {is_permissions_revoked: true, is_unlinked: true}  

 

2) User does not exist and if API call succeeds:  


Call: ss_mi.ssmi_unlink_user('xyz@gmail.com')  

Response: Object {is_permissions_revoked: false, is_unlinked: false}  

 

3) If API call fails:  


Call: ss_mi.ssmi_unlink_user('xyz@gmail.com')  

Response: Object {reason: "Error while Unlinking Social Login User", error: true}