I’ve recently been involved in a project whose the purpose was to extend the Corporate Intranet with the Video Portal of Office 365. While the 365 UI sounds the natural location to upload/edit videos, it might not be the default location to list them. In the context of a Corporate Intranet home page, one might want to list the available videos and their thumbnails, and let the users decide whether or not they want to watch a given video.
In that case, you have two different options to download the metadata of the videos into your home page :
1) Using ADALJS but that approach requires the end-user to sign in to Office 365, and you’d better have an AngularJS based Intranet.
2) Using ADAL server-side. This approach is particularly suited for “public” channels (typically your corporate communication channel). So, if you don’t need security trimming, you can interact as an app-only with the Video Portal and download the metadata.
If you opt for option 2, beware that while you’ll be perfectly able to download the video metadata, you’ll encounter some problems which I’ll detail later. To be more concrete, say that you target one channel in particular from your .NET server-side component :
and the REST API returns this:
<m:properties> <d:ChannelID m:type="Edm.Guid">e6233971-94ba-4177-8d19-aa09a5be0096</d:ChannelID> <d:CreatedDate m:type="Edm.DateTime">2015-02-24T11:18:44Z</d:CreatedDate> <d:Description></d:Description> <d:DisplayFormUrl>https://eyskens.sharepoint.com/portals/MASTIC/pVid/Forms/DispForm.aspx?ID=5</d:DisplayFormUrl> <d:FileName>visitesite.mp4</d:FileName> <d:OwnerName>stephane eyskens,#i:firstname.lastname@example.org,#email@example.com,#firstname.lastname@example.org,#stephane eyskens,#https://eyskens-my.sharepoint.com:443/User%20Photos/Profile%20Pictures/silverit_eyskens_onmicrosoft_com_MThumb.jpg?t=63563165738,#test,#</d:OwnerName> <d:ServerRelativeUrl>/portals/MASTIC/pVid/visitesite.mp4</d:ServerRelativeUrl> <d:ThumbnailUrl>https://eyskens.sharepoint.com/portals/MASTIC/pVid/visitesite.mp4.PNG?VideoPreview=1</d:ThumbnailUrl> <d:Title>Visite</d:Title> <d:ID m:type="Edm.Guid">fc11dae3-56a6-4c85-a6cd-96681fd9f73a</d:ID> <d:Url>https://eyskens.sharepoint.com/portals/MASTIC/pVid/visitesite.mp4</d:Url> <d:VideoDownloadUrl>https://eyskens.sharepoint.com/portals/MASTIC/_layouts/15/download.aspx?SourceUrl=https%3A%2F%2Feyskens%2Esharepoint%2Ecom%2Fportals%2FMASTIC%2FpVid%2Fvisitesite%2Emp4</d:VideoDownloadUrl> <d:VideoDurationInSeconds m:type="Edm.Int32">666</d:VideoDurationInSeconds> <d:VideoProcessingStatus m:type="Edm.Int32">2</d:VideoProcessingStatus> <d:ViewCount m:type="Edm.Int32">-1</d:ViewCount> <d:YammerObjectUrl>https://eyskens.sharepoint.com/portals/hub/_layouts/15/videoplayer.aspx?v=https%3A%2F%2Feyskens%2Esharepoint%2Ecom%2Fportals%2FMASTIC%2FpVid%2Fvisitesite%2Emp4</d:YammerObjectUrl> </m:properties>
In order to get this information, your .NET component had to acquire a token from Azure and call the Video Portal REST API to get the metadata. So far, so good but…because there is always a but, if you try to display the video thumbnails thanks to the ThumbnailUrl attribute, it’s not going to work because your browser hasn’t authenticated against 365…So, if you want to prevent this, you can use the SSO trick I explained in my previous post http://www.silver-it.com/node/207/. Another problem you will encounter is the fact that (at the time of writing), the ViewCount attribute always returns “-1″…which is rather useless to say the least. If you read Microsoft’s documentation, to get the actual number of views, you must use the Search engine like this:
but here we’ve got another problem : the server-side component authenticates as an App (because we don’t want to prompt the users to sign in) and SharePoint’s search cannot be consumed with the app-only policy…
ADALJS allows us to get all the info and to display thumbnails and get the right amount of views via the search engine because we must pre-authenticate the user…
ADAL (from a server-side component) allows us to download all the metadata using app-only permissions. It allows us to avoid prompting users to sign-in which is always good in the context of an Intranet + it saves a lot of roundtrips since you can simply cache the metadata BUT, you will have to cheat to get the thumbnails showing up correctly, and I didn’t find a way to retrieve the actual number of views…