none
How to integrate Sharepoint Online Webpart File Preview into external application by using WOPI Url. RRS feed

  • Question

  • Hi,

    I'm trying to integrate the Powerpoint and PDF Preview of a Webpart into an external application.

    I'm loading the page using the Sharepoint Online REST API and and as part of the Canvas1, SharePoint is returning the Webpart containing the wopiurl for the embedded document.

    I'm trying to load the content of the wopiurl by sending a request (GET) including the Sharepoint Online OAuth2 Bearer access token as Header (server to server).

    http://<tenant>.sharepoint.com/sites/<site>/_layouts/15/Doc.aspx?sourcedoc=%7b<GUID>%7d&file=<filename>.pptx&action=embedview&mobileredirect=true

    SharePoint Online is returning a response with HTTPStatus 401.

    If I load the url directly in the browser everything works. The request will be redirect to:

    https://<tenant>.sharepoint.com/:p:/r/sites/<site>/_layouts/15/Doc.aspx?sourcedoc=%7b<GUID>%7d&file=<filename>&action=embedview&mobileredirect=true

    => Make sense as I'm looked into Sharepoint Online/Office 365.

    Do I have add an WOPI accesstoken like decribed in the following links?

    https://wopi.readthedocs.io/projects/wopirest/en/latest/concepts.html#term-access-token

    https://wopi.readthedocs.io/projects/wopirest/en/latest/bootstrapper/GetNewAccessToken.html

    Can I create a new access token for WOPI by exchanging/using my existing OAuth2 Access Token?

    Is there an REST API to generate the access token for SharePoint Online?

    Thanks

    Patrick


    • Edited by pheinzelmann Thursday, October 10, 2019 12:11 AM Updated
    Thursday, October 10, 2019 12:02 AM

All replies