question

JonathanKorach-7803 avatar image
0 Votes"
JonathanKorach-7803 asked ·

I am using OneDrive file picker and Graph api to embed documents in my web app, not sure that the correct way.

Hi,

In the doc,driveItem: preview mention that driveItem: preview request generates a short-lived URL, I would like to know what is the expiration of the link (hour, day, week, month, etc..).

More details and to give things into context, in our web app we enable users to upload files, and also upload from their cloud drives, such as Google Drive, DropBox, and OneDrive.

Most of our users are using OneDrive for businesses.

I tried using the request: POST /drives/{driveId}/items/{itemId}/preview , after the user selects the file from the file picker, and I using the getUrl to embed the file into an iframe.(the getURL as src)
I noticed that the URL contains access_token, and I deleted it before saving it, and I noticed that the iframe still works fine, and allows only users with permission to see the file, is this is a good usage of that?

Are there any pitfalls that I didn't notice?

Thank's

microsoft-graph-filesmicrosoft-graph-applications
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JonathanKorach-7803
Welcome to Q&A forum.
Based on your description, your issue seems to be more related to Microsoft Graph and OneDrive file picker. As tag "office-onedrive-client-itpro" focuses on general issues about OneDrive client, I will remove the tag. Thanks for your understanding.

1 Vote 1 ·

1 Answer

Deva-MSFT avatar image
0 Votes"
Deva-MSFT answered ·

If you use driveItem: preview, this action allows you to obtain a short-lived embeddable URL for an item in order to render a temporary preview. Unfortunately its not documented about the duration. The preview action is currently only available on SharePoint and OneDrive for Business.

In case if you want to obtain long-lived embeddable links, use the createLink API instead.


· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Deva thank's for your answer.
I am familiar with this documentation, the issue is that creatLink endpoint doe's not generating URL that could be embedded .
I wonder if the only reason of the short-liven URL ,is due to the access_token that is part of the URL, in my use case I don't need this token because I want to leave the permission to OneDrive/SharePoint therefore I tried to remove this token and the iframe rendered successfully also 2 days after the URL generated. I want to know if this could work for me to save the URL that way for a long-live.
Do you think it would work?

Thanks!

0 Votes 0 ·