Table of contents
TOC
Collapse the table of content
Expand the table of content

Retrieve the API entry point and sign in a user

Ajinkya Kher|Last Updated: 11/23/2016
|
1 Contributor

Applies to: Skype for Business 2015

The Application object is created by invoking the Application class constructor with the new keyword. This is the only SDK object that can be constructed in application logic. All other SDK types are accessed by reading properties or invoking functions on application.

The SignInManager.SignIn method and the SignInManager.SignOut method are asynchronous and return a Promise object. Use the Promise#then method to set operation success or failure callbacks.

Note: To enable audio/video functionality for IE 11 and Safari you need to install the Skype for Business Web App Plug-in. It is available for Windows and Mac computers:

Get the SDK entry point and sign in a user

Add a reference to the bootstrapper to your HTML file.

BY USING THE SOFTWARE LOCATED HERE: https://swx.cdn.skype.com, YOU ACCEPT THE Microsoft Software License Terms IF YOU DO NOT ACCEPT THEM, DO NOT USE THE SOFTWARE.

Note: These license terms apply to the use of the content from the domain swx.cdn.skype.com.

<script src="https://swx.cdn.skype.com/shared/v/1.2.15/SkypeBootstrap.min.js"></script>

Download the SDK package. In the following snippet, we are using public preview API keys. You can see all available API keys by reading Skype Web SDK Production Use Capabilities


var config = {
 apiKey: 'a42fcebd-5b43-4b89-a065-74450fb91255', // SDK
 apiKeyCC: '9c967f6b-a846-4df2-b43d-5167e47d81e1' // SDK+UI
}; 

Skype.initialize({ apiKey: config.apiKey }, function (api) {
  Application = api.application; // this is the Application constructor
}, function (err) {
  console.log("cannot load the sdk package", err);
});

Call the Application constructor.

app = new Application;

Sign the user in by calling the Application#signInManager.signIn method.

app.signInManager.signIn ({
  username: '****',
  password: '****'
}).then(() => {
  console.log("signed in as", app.personsAndGroupsManager.mePerson.displayName());
}, err => {
  console.log("cannot sign in", err);
});

Note: If sign in fails or you call signOut, you must create a new Application object and make the new sign in attempt with that object. The original application object will not be able to attempt a new sign in operation.

The following example uses the password grant authentication to sign a user in with a username and password.

<!doctype html>
<html>
<head>
  <title>My Skype Web SDK app</title>
  <script src="https://swx.cdn.skype.com/shared/v/1.2.15/SkypeBootstrap.min.js"></script>
</head>
<body>
  <script>
    Skype.initialize({ apiKey: 'a42fcebd-5b43-4b89-a065-74450fb91255' }, api => {
      var app = new api.application;

      app.signInManager.signIn ({
        username: '****',
        password: '****'
      }).then(() => {
        console.log("signed in as", app.personsAndGroupsManager.mePerson.displayName());
      }, err => {
        console.log("cannot sign in", err);
      });
    }, err => {
      console.log("cannot load the sdk package", err);
    });
  </script>
</body>
</html>
© 2017 Microsoft