Pages Menu
TwitterRssFacebook

Posted by on Apr 30, 2015 in Learn Skype Web SDK | 15 comments

Learn Skype Web SDK Day 1 : Logging In

Learn Skype Web SDK Day 1 : Logging In

This is one post in a series of more than 30, devoted to helping you get up to speed quickly with the new Skype Web SDK. Each lesson comes with source code (in GitHub) and a working demo page so you can see what it does. Check out the full list of posts on the Skype Web SDK page.

View Demo

Getting signed in using Skype for Web API’s predecessor, UCWA, used to be a complicated process involving trying different URLs, passing around tokens and generally trying to convince the server to let you in. One of the real benefits of the Skype for Web API is that it’s greatly simplified this process into a single JavaScript call.

The starting point for using the Skype for Web API is the Application object. This is actually the only object in the API which you construct yourself. Everything else hangs off this Application object. An Application object represents an endpoint which you can sign in and do things with. You can create multiple Application objects and have each one sign in as a different user, if you need to.

The signInManager object is responsible for navigating all the different types of authentication and getting you logged in. There are just two commands: signIn and signOut.

Because it’s so new we’re still understanding how everything works, where all the bits are, and what does what. At first glance, it looks like the actual JavaScript code that is the SDK is being presenting using almond, an AMD loader. This could be done for speed or ease of updating. Whatever, the reason – we can’t just add a script tag and get coding. We need to load in the script. This is done like this:

[code language=”javascript”]
var client;
$(function () {
‘use strict’;

Skype.initialize({
apiKey: ‘SWX-BUILD-SDK’,
}, function (api) {
client = new api.application();
}, function (err) {
alert(‘Error loading Skype Web SDK: ‘ + err);
});

….

});
[/code]

There are different types of credentials you can supply when logging in. This example is going to look at basic authentication: where a Skype for Business username and password are supplied. However, logging in via Windows Authentication and OAuth are also supported.

To sign in using basic authentication, called the signIn method passing two values: username and password:

[code language=”javascript”]

var client = new Skype.Web.Model.Application;
client.signInManager.signIn({
username: $(‘#username’).val(),
password: $(‘#password’).val()
}).then(function () {
//log in worked!
alert(‘Logged in!’);
}, function (error) {
//Something went wrong.
alert(error);
});

[/code]

The method returns a promise, so you can react to either a succesful login or a failure.

It’s useful to be able to know the current logged-in state, and the signInmanager can help with that to. It exposes a property: state, which gives you the current logged-in state. Valid states are:

  • SignedOut
  • SigningIn
  • SignedIn
  • SigningOut

The example below shows a webpage with a username and password button, and a Sign In button, which performs a sign-in to Skype for Business.

[code language=”javascript”]

[/code]

Demo Online

You can try this code out against your own Skype for Business environment by going to the demo page. From here you can also download the code from GitHub if you want to host it locally, or take it and use it in your next project.

Disclaimer: This is sample code, intended to inform and educate. It is not production-ready and is lacking key components such as error handling. You use it entirely at your own risk. You should fully understand the effects, limitations and risks of the code before executing, and understand the implications of any set-up steps. By using these code examples you are using the Skype Web SDK, so you should read the Skype Software License Terms to which you are agreeing.

Good to Know

15 Comments

  1. Hi, I tried your online demo program on ‘Signing In using Skype web SDK’, and am facing 403-forbidden issue while auto-discovery. The internal auto-discovery fails(it should be) but the external discovery should succeed as the web server has the Lync server running that applies to Skype for Business. Please advise.

    Thanks!

  2. Did you use Set-CSWebServerConfiguration on all your FEs, Edges and Directors? It’s covered in my Server Prerequisites post.

  3. I have followed the server prerequisites and downloaded the Skype Web SDK Samples Preview. When I try to log in, it fails with the error ‘Can’t sign in, please check the user name and password’. Then it says ‘Error: AssertionFailed’. Using google chrome, I have found the line is from the SDK-build.js (from the skype cdn) on line 569. Can you help? It may be useful for you to create a troubleshooting link or FAQ link somewhere.

  4. I have run on demo site, but I not work yet. Do I have to follow Server Prerequisites? such running at least Lync Server 2013 and run this %ProgramFiles%\Microsoft Lync Server 2013\Deployment\Bootstrapper.exe!

    Thank you
    Best & regards
    Rith

  5. hi Tom,
    I have test the sample of login ,but I got a problem as same as Jagdip said. I try to login with a normal skype account, it does not work. Does the Skype Web SDK just work for Skype for Business? I’m not very clear about this. Can you help me?
    If it just for Skype for Business, there is any way that I can put the skype into my windows app(only need contacts and chat functionality)?

    Thank you.

  6. I have done the prerrequisites and demos are not working for me.

    What i see in IE console is (however, i’m typing my sip address and password correctly):

    Error: InvalidCreds
    {
    [functions]: ,
    __proto__: { },
    code: “InvalidCreds”,
    description: “InvalidCreds”,
    message: “InvalidCreds”,
    name: “Error”,
    response: { },
    stack: “Error: InvalidCreds
    at Anonymous function (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:5831:29)
    at handle (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:2220:33)
    at Anonymous function (https://swx.cdn.skype.com/build2015/v5/SDK-build.js:698:25)”
    }

    SCRIPT5007: No se puede obtener la propiedad ‘prototype’ de referencia nula o sin definir
    jquery-1.7.2.min.js (32,6680)

    What could be the error?

  7. Great article. Do you have one sample that leverages integrated windows auth as against basic?

  8. Hello, how to get the script working when your SIP address is not the same as the Active Directory UPN login name?

  9. i got error NoFQDN ,what does it mean

  10. I got error NoFQDN while signing in

  11. Hi Guys,

    I went through some issues, but finally succeeded in using Skype Web SDK. So I’d like to share my experience for those trying to do the same.

    First, I wanted to use Skype Web SDK using a local lab, so everythin is running on my computer which has access to internet.

    I’ve got : 1 VM for the AD/PKI, 1VM for a FE Standard Edition, 1VM for a IIS Server running the Skype Web SDK samples, 1VM for a IIS with ARR functionality.
    That’s all I needed to make it work!

    I won’t get through the installation process of a SfB FE, just follow that procedure : http://www.msic.ch/Portals/0/Images/Skype%20for%20Business%20Server%202015%20Step%20by%20Step%20for%20Anyone%20-%20Installing%20and%20Upgrading_REV_05.pdf

    Then, create the VM SkypeWebSDK that will run IIS and Skype Web SDK samples, joined to the domain. This machine has one leg on the internet network and one on the LAN where other VMs are running (follow the same configuration as an edge for example, default gateway and dns server set up on the external NIC, not on the internal, add in the “hosts” file the lyncdiscoverinternal fqdn, the fqdn of the FE, and the external web services pointing to the ARR VM. Finally, copy create a new website in IIS with the proper bindings as explained here : http://blog.thoughtstuff.co.uk/2015/04/learn-skype-web-sdk-day-1-setting-up-your-development-environment/

    Then on your SfB FE, trust the application by adding your skypewebsdk VM :
    $x = New-CsWebOrigin -Url “{https://SkypeWebSDK.myPoC.local}”
    Set-CsWebServiceConfiguration -CrossDomainAuthorizationList @{Add=$x}

    As I don’t have a platform with edge servers, I just created a reverse proxy with ARR. This way, when lauching samples from the SkypeWebSDK VM, I’ll have access to external web services, as if I was on internet.
    For the ARR VM, it has only one leg in the LAN. Follow that procedure (you will need to set up external web services url only, no need for OWA/autodiscover) : http://www.ucguys.com/2014/08/using-iis-arr-30-on-windows-server-2012r2-as-a-reverse-proxy-for-lync-server-2013.html
    Regarding the certificate part, ADCS web server template has the “export private key” option greyed out on the web enrollment page. To create your certificate from the https://AD/certsrv web enrollment service, you have to, on your AD, open certtmpl.msc, duplicate the template “Web Server” and rename it as you wish, ensure that in the “subject name” section, you use “Supply in the request”. Then open the “Certificate Authority” tool, right clic on “Certificate template”, select “new” and add the template you’ve just created. Then you should be able to create a certificate in the .pfx format using ADCS web enrollment.
    Finally, because the given samples do not ask for domain\username, you need to have the same UPN as your SIP address to login in. To do so, open AD domain and trusts, right clic on “Active Directory Domains and Trusts”, clic properties and add the SIP domain you’re using. Then go to AD users and groups, select your user, and in account section, change its UPN suffix to the domain you’ve just added.
    On all your VM, ensure you open proper ports on the firewall.
    Now you should be able on the SkypeWebSDK VM to launch the samples (I used firefox to get through IE blocking settings): http://skypewebsdk.mypoc.local/UC, and here you go!
    PS : do not forget to enable your Skype for Business user and allow remote access.
    If you have any information regarding the domain\username credentials that can be added in the form to log in without changing the UPN, please tell me 🙂
    Everyone have fun!
    Regards,
    Stephen

  12. is it possible to host the Web SDK locally without using the CDN?

Trackbacks/Pingbacks

  1. SkypeDevQ: Using Skype Web SDK with on-premise Skype for Business | The thoughtstuff Blog - […] There’s more information about adding a new domain for access using Skype Web SDK on the Learn Skype Web…

Post a Reply

Your email address will not be published. Required fields are marked *

This site uses cookies to help make this website better. By continuing to use this site we’ll assume you’re OK with that (implied consent).