Not Able to Get Applications Url for Skype for Bus

2020-03-07 08:00发布

问题:

I'm trying to use the REST API in Skype for Business Online by following the instructions here: https://msdn.microsoft.com/EN-US/library/office/mt590891(v=office.16).aspx.

I make the first call to the discovery service, and then get the discovery URL back for the user; it looks like this for me: https://webdir0b.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user

I then make the call to Azure and successfully get an access token back for https://webdir0b.online.lync.com. The next step is where things break down - I make a request again to the discovery Url for the user and include the access token. The call returns successfully, but the problem is that it doesn't have the "applications" url in the payload as described in the documentation. Instead it returns the same exact info as I got when I called the general discovery endpoint (https://webdir.online.lync.com/autodiscover/autodiscoverservice.svc/root). I've triple checked that I'm calling the correct endpoint so...any hints as to why I'm not getting the expected payload when calling the discovery Url for the user?

回答1:

(Am I really replying to Steve Pescka? :o)

In my case performing GET on the user resource
GET https://webdir0e.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user?originalDomain=contoso.onmicrosoft.com

returns the following

 <resource rel="user" href="https://webpoolam30e08.infra.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user" xmlns="http://schemas.microsoft.com/rtc/2012/03/ucwa">  
   <link rel="applications" href="https://webpoolam30e08.infra.lync.com/ucwa/oauth/v1/applications" revision="2" />
   <link rel="xframe" href="https://webpoolam30e08.infra.lync.com/Autodiscover/XFrame/XFrame.html" />
 </resource>

So it contains the URI for applications resource, where to POST in order to create your application. I have an O365 E5 license



回答2:

I'll try and answer as short as possible - I got this working. 1st issue - when you don't get "applications" in the result, you should have a "redirect" value instead. Keep following that and doing your GET against it (using the process of getting access tokens and adding the auth header) and eventually you should get the applications Url. 2nd issue - after you get your applications URL, you need to go get another access token and use the host name of the applications URL as the resource ID. Then you can post and create your app. Really hope this helps someone. :-)



回答3:

Correct. When the results of calling the user resource does not include applications, it will include a redirect value. Here's an example:

A call here:

https://webdir0b.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user

May return the following:

{"_links":{"self":{"href":"https://webdir0b.online.lync.com/Autodiscover/AutodiscoverService.svc/root/user"},"xframe":{"href":"https://webdir2a.online.lync.com/Autodiscover/AutodiscoverService.svc/root/xframe"},"redirect":{"href":"https://webdir2a.online.lync.com/Autodiscover/AutodiscoverService.svc/root"}}}

Which includes this redirect

"redirect":{"href":"https://webdir2a.online.lync.com/Autodiscover/AutodiscoverService.svc/root"}}}

To continue, you'll then need to make an Azure AD auth call, passing ONLY the value of the protocol://servername as the resource. This means reducing the following:

https://webdir2a.online.lync.com/Autodiscover/AutodiscoverService.svc/root

To be just this:

https://webdir2a.online.lync.com/

Now that you have a valid token for webdir2a.online.lync.com, you'll then need to append "/oauth/user" to the re-direct URL. You'll notice the initial call included this in the URL whereas the redirect URL doesn't.

Call the updated re-direct URL

https://webdir2a.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user

And you should get what you're after:

{"_links":{"self":{"href":"https://webpooldm12a04.infra.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user"},"applications":{"href":"https://webpooldm12a04.infra.lync.com/ucwa/oauth/v1/applications","revision":"2"},"xframe":{"href":"https://webpooldm12a04.infra.lync.com/Autodiscover/XFrame/XFrame.html"}}}

Which is the applications resource

"applications":{"href":"https://webpooldm12a04.infra.lync.com/ucwa/oauth/v1/applications","revision":"2"}

For the interested, I've created a .NET-based console app that demonstrates how to sign in to Skype for Business Online via the UCWA API - and in doing so, handles the autodiscovery process, re-directs, application creation, amongst other things.



回答4:

I'm trying to use the REST API in Skype for Business Online by following the instructions here: https://msdn.microsoft.com/EN-US/library/office/mt590891(v=office.16).aspx.

I make the first call to the discovery service, and then get the discovery URL back for the user; it looks like this for me: https://webdir0b.online.lync.com/Autodiscover/AutodiscoverService.svc/root/oauth/user

I then make the call to Azure and successfully get an access token back for https://webdir0b.online.lync.com. The next step is where things break down - I make a request again to the discovery Url for the user and include the access token. I get 500 - Internal server error.There is a problem with the resource you are looking for, and it cannot be displayed.