2014-11-21 38 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/'; 
     } 
     } 
    } 
    });