OneDrive API - createLink with type "embed" returns dead urls

Copper Contributor

Hello. I've just started using OneDrive Rest API (I'm using https://github.com/OneDrive/onedrive-sdk-python if that's important). What I'm trying to accomplish is to get embed url for some pictures from OneDrive.

 

I get an error while using createLink method with type = "embed". I receive an url in format "https://onedrive.live.com/embed?resid=abcdef&authkey=123456" that leads to non-working page:

 

изображение.png

 

If I try to get link from onedrive website interface (using "Embed" option) it works fine but it's in different format (https://yfzapq.am.files.1drv.com/abcdefg123456?height=504&width=504).

 

Am I missing something? Is there way to get working embed urls via OneDrive API?

 

PS I've found that some people also receiving the same issue - https://stackoverflow.com/questions/58805214/onedrive-rest-api-embed-download-url

What I've also found that in 2016 ember urls were unavailable in API (https://github.com/OneDrive/onedrive-api-docs/issues/102). Maybe nothing changed since then.

1 Reply

Figured the solution:

 

I've looked up how exactly onedrive is getting embed url when you use "Embed" on website. Turned out it uses other function than createLink - it uses /thumbnails.

And you can also use this function as it is a part of Rest API - as result you'll get links in format https://yfzapq.am.files.1drv.com/abcdefg123456?width=768&height=1024&cropmode=nonethat that seems to last forever. If you remove all the parameters from url (?width=768&height=1024&cropmode=none) it will lead to the original image.

PS The problem with this method - thumbnail urls are dying within 4 hours (from my experience).