2014-11-21 37 views
1

当使用Yammer SDK和使用yam.platform.login方法时,当身份验证失败或用户关闭对话框窗口时,我没有得到任何回调。这是一个错误还是你在Yammer集成任务中看到的东西?调用yam.platform.login时没有回调

我的代码

yam.platform.getLoginStatus(function (response) { 
    if (response.authResponse) { 
    } 
    else { 
     yam.platform.login(function (response) { 
      if (response.authResponse) { 
       console.dir(response); 
      } 
      else { 
       ### CODE NEVER EXECUTED IF LOGIN FAILS OR USER CLOSE POPUP### 
      } 
     }); 
    } 
}); 

回答

0
  1. 确保添加您的Web应用程序URL您注册Yammer的应用程序,以 “JavaScript源”。
  2. 请确保您已将您的网络应用程序网址添加到“受信任的网站”和其他Yammer网址。
0

当用户当前登录到家庭网络(应用程序注册的网络)以外的网络时,出现此问题(在yam.platform.login上没有回调)。如果您的用户使用多个网络,则可能需要将您的应用添加到全局应用注册。

另一种方法就是'尝试'下面的方法。这对我们很有用,因为它只需要发生一次(以获得身份验证令牌)。

yam.getLoginStatus(function(resp){ 
    if (resp.authResponse) { 
     //success 
    } else { 
     // not logged in 
     var yamLoginSuccess=0; 
     try { 
     yam.platform.login(function (response) { //prompt login 
      console.log('no response here if user in another network'); 
      if (response.authResponse) { 
      //success 
      yamLoginSuccess=1; 
      } 
     }); 
     } 
     catch(err) { 
      // does not throw an error so this bit is not helpful 
     } 
     finally{ 
     if(yamLoginSuccess===0){ 
      alert('Need to be logged into the home yammer first :-/ /n ' 
      + 'Redirecting now, hit back to come back'); 
      window.location='https://www.yammer.com/YOURNETWORK/'; 
     } 
     } 
    } 
    });