spiroski
spiroski

Reputation: 639

Can't authenticate to Skype For Business Online UCWA

I'm having trouble authenticating to S4BO. I have registered my app (in azure portal) and it's working correclty with the webSDK demo at https://ucwa.skype.com/websdk The process I follow is the following one:

  1. I do a OAuth link redirect with the following code:

    https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&resource=https://webdir.online.lync.com&redirect_uri=http://myurl.dev/skype
    
  2. Get the auth code that has been returned and use it to generate an access token:

    POST https://login.microsoftonline.com/common/oauth2/authorize?response_type=code&client_id=db01d1f5-f2a3-4d82-b4bc-6b3b4071d7df&resource=https://webdir.online.lync.com&redirect_uri=http://acme.intranet.dev/skype
    
         grant_type=authorization_code
         code=$thecodehere
         client_id=$clientidhere
         client_secret=$clientsecrethere
         redirect_uri=$sameuriasbefore
    
  3. After this I have my access token. Now I need my user url. So I do autodiscover

    GET https://lyncdiscover.mydomain.onmicrosoft.com
    

and I receive a result something like:

{
"_links": {
    "self": {
      "href": "https://webdir1e.online.lync.com/Autodiscover/AutodiscoverService.svc/root?originalDomain=mydomain.onmicrosoft.com"
    },
    "user": {
      "href": "https://webdir1e.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=mydomain.onmicrosoft.com"
    },
    "xframe": {
      "href": "https://webdir1e.online.lync.com/Autodiscover/XFrame/XFrame.html"
    }
  }
}
  1. I try to log in at the user url:

    GET https://webdir1e.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=mydomain.onmicrosoft.com
    HEADERS:
    Authorization: Bearer + theAccessTokenFromAbove
    Referer: https://webdir1e.online.lync.com/Autodiscover/XFrame/XFrame.html
    

And after this I get 403 Unathorized. Where am I going wrong?

Upvotes: 1

Views: 1226

Answers (1)

Andrey Markeev
Andrey Markeev

Reputation: 1404

  1. Get the auth code that has been returned and use it to generate an access token

On this step as a resource you need to specify resource=https://webdir1e.online.lync.com (notice 1e) to get access to this particular hub.

Actually you will have to authenticate on every new server starting from this point, so on all the webdirXX and then on the webpoolXXXXX.

I wrote a huge interactive article that describes the requests flow in detail (after myself spending a week to reverse engineer how outlook.com does that because MSDN documentation is - at least at the time of writing this - incomplete and incorrect), maybe it can be of use:

If you configure app redirect URL to the article URL (temporarily of course), you can even test the queries right from there.

Additionally, autodiscovery and authentication code "in one piece" can be found on Github (with live demo):

Upvotes: 0

Related Questions