how to redirect user login from other server? The user login is from the other drupal site using cas(Central Authentication Service). Then it will lead to my main site and an authenticated user can view the contents. The main site is used Drupalgap to redesign the interface for mobile.

Now, when using the web browser, it works fine to login and start to view the contents. However, I don't know how to do it for Drupalgap. I saw some apps can login with the account from other sites, once the login is successful, it will redirect and come back to the app.

Does anybody know how to do it?

My attempt is trying to use the login url from the other site. 

bl('Login', 'www.example.com/cas', { InAppBrowser:true });

This will open a new web browser, not inside my app page. When successfully login, there's a link to go back to my main site. These are operating through the new web browser, not inside my original app.
On the Drupal side, create a custom module to implement hook_form_alter() and use it to attach a custom #submit handler to the user_login_form. In the custom submit handler, you can redirect the user to the headless DrupalGap web app:

/**
 * Implements hook_form_alter().
 */
function example_form_alter(&amp;$form, $form_state, $form_id) {
  if ($form_id == 'user_login_form' &amp;&amp; arg(0) == 'drupalgap') {
    $form['#submit'][] = 'example_user_login_form_submit';
  }
}

function example_user_login_form_submit($form, &amp;$form_state) {
  $uid = 123; // This id will be somewhere in the $form or $form_state object.
  drupal_goto('https://example.com/#user_' . $uid);
}


Replace drupalgap with your service endpoint path, but by default it is drupalgap.