2017-04-07 71 views
0

我正在使用Skype Web SDK以下列方式獲取用戶的聯繫人列表。Skype Web SDK - 維護用戶會話

Skype.initialize({ 
       apiKey: 'a42fcebd-5b43-4b89-a065-74450fb91255', 
       }, function (api) { 
         var Application = api.application; 
         var client = new Application(); 
         client.signInManager.signIn({ 
          username: sip, 
          password: pwd 
         }) 

這項工作正常,當我提供用戶名(SIP)和密碼。但是,當我重新加載頁面時,我必須再次提供憑證,因爲應用程序會重新初始化。有沒有辦法在初次登錄後維護用戶會話一段時間,以便頁面刷新不需要再次詢問憑證?

我已經瀏覽了微軟有和無法找到方法的示例和文檔。我還嘗試在初始化和登錄後將client對象存儲在localStorage中,但是當我嘗試重新使用localStorage中的對象獲取聯繫人列表時,該對象不起作用。

回答

0

http://officedev.github.io/skype-docs/Skype/WebSDK/model/api/interfaces/jcafe.signinmanager.html#signin最後一個例子解釋說您可以存儲oauth標記並將其用作未過期的標記。使用OAuth

sm.signIn({ 
 
    username: "[email protected]", 
 
    password: "password1", 
 
    id: "273867-234235-45346345634-345" 
 
});

要登錄到Skype for Business線上同時處理:

要連接到現有的應用程序的事件通道,指定應用程序的ID檢索OAuth令牌的 邏輯:

sm.signIn({ 
 
client_id: '123-456', 
 
origins: [ 'https://webdir.online.lync.com/AutoDiscover/AutoDiscoverservice.svc/root' ], 
 
cors: true, 
 
get_oauth_token: function(resource) { 
 
    // Return a valid unexpired token for the specified resource if you already have one. 
 
    // Else, return a promise and resolve it once you have obtained a token. 
 
    return 'Bearer eyJ0e...'; 
 
} 
 
});

+0

很抱歉,但我不知道我是否完全理解了答案。在第一個例子中,我從哪裏得到id?在第二個示例中,我從哪裏獲取OAuth令牌? – Reddy