简体   繁体   中英

Skype Web SDK - Maintain a user session

I am using Skype Web SDK to get a user's contact list in the following manner.

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
                        })

This works fine when I provide the username(sip) and password. However, when I reload the page, I have to provide the credentials again because the app re-initializes. Is there a way to maintain the user's sessions for a while after the initial login so that the page refreshes wouldn't need ask for credentials again?

I have looked through the samples and docuementation that Microsoft has and couldn't find a way. I've also tried to store the client object in the localStorage after the initialization and sign in, but when I tried to reuse the object from localStorage to get the contact list, it did not work.

http://officedev.github.io/skype-docs/Skype/WebSDK/model/api/interfaces/jcafe.signinmanager.html#signin last example explains that you can store oauth token and use it as unexpired token.

To connect to an existing app's event channel, specify id of that app:

 sm.signIn({ username: "user1@company.com", password: "password1", id: "273867-234235-45346345634-345" }); 

To sign in to Skype for Business Online using OAuth while handling the logic of retrieving OAuth tokens yourself:

  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...'; } }); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM