Interactive Function

The interactive function instructs the SSO script to use interactive authentication. It uses callbacks to monitor the state of the interactive session. CRM Desktop SSO runs the statement that occurs immediately after the statement that calls the interactive function only after the interactive authentication finishes. While interactive authentication runs, the SSO script gets notifications from the function that the callback parameter identifies. This callback delivers the information that this script requires to monitor the interactive authentication. It can send a request to stop the interactive authentication when the interactive session finishes.

The interactive function uses the following format:

interactive(ia_state, callback)

where:

  • ia_state is a string that identifies the object that contains information about interactive authentication.

  • callback is a string that identifies the function that CRM Desktop SSO calls on every change that occurs in the ia_state.status. This callback must return a Boolean value. If it returns True, then CRM Desktop SSO stops the interactive authentication. ia_state is an object that the sso_client.create_ia_state function creates and then uses to control how interactive authentication runs. The callback is a function that returns one of the following values:

    • true. Interactive authentication finished.

    • false. Interactive authentication has not yet finished.

The following example does a simple callback for interactive authentication. It does not do any processing. It always return false to indicate that CRM Desktop SSO must display the native browser dialog box in every subsequent web page where the user navigates:

function ia_callback(ia_state) 
{
  switch (ia_state.status) {
    case "before":
    // before navigate to url
    break;
    case "finished":
    // page download complete
    break;
    case "cancelled":
    // user closed dialog
    break;
}
  return false;
}

This example includes the following code. This code is part of the request handler function:

var ia_state = sso_client.create_ia_state();
ia_state.url = url;
ia_state.dialog.width = 1024;
ia_state.dialog.height = 768;
ia_state.dialog.title = "SSO";
ia_state.dialog.visible = false;
sso_client.interactive (ia_state, ia_callback);