Reputation: 1406
The scenario is that we already have SSO an OAuth authentication enabled with an app to Microsoft. We're able to talk to the Graph API and collect folder and file information etc and query all manner of things through this.
The problem however, is when for example one of the files is a Picture, and we try to show a preview in a popup like in lightbox.
From the displayed folder in the app, if we open up the SharePoint version, we're asked to authenticate to SharePoint. After this, the previews work fine.
So the problem is that merely being authenticated for Graph API, does not seem to provide sufficient privileges to be authenticated with SharePoint.
Any work arounds?
I think that we need to somehow check if we're authenticated with SharePoint and force authentication if we're not.
Upvotes: 0
Views: 257
Reputation: 12245
It looks you are trying to use URL to an image file stored in a SharePoint directly, like this: https://your.sharepoint.com/sites/some/picture.jpg
The problem is that API (either graph or rest) is using different authentication mechanism (bearer tokens) than SharePoint UI (cookies).
I have worked around this situation for us by downloading the picture separately using the API, then storing it in a blob, and then for the preview providing URL like blob://bla-bla-bla
using URL.createObjectURL
. You can also cache images locally using IndexedDb for example after the first download for performance.
Upvotes: 1