Skip to content

Instantly share code, notes, and snippets.

@JoeThunyathep
Created May 24, 2020 16:08
Show Gist options
  • Save JoeThunyathep/5293f3bbdb87840b67aa027b4ee0b4d0 to your computer and use it in GitHub Desktop.
Save JoeThunyathep/5293f3bbdb87840b67aa027b4ee0b4d0 to your computer and use it in GitHub Desktop.
Generate direct download link from OneDrive
import base64
def create_onedrive_directdownload (onedrive_link):
data_bytes64 = base64.b64encode(bytes(onedrive_link, 'utf-8'))
data_bytes64_String = data_bytes64.decode('utf-8').replace('/','_').replace('+','-').rstrip("=")
resultUrl = f"https://api.onedrive.com/v1.0/shares/u!{data_bytes64_String}/root/content"
return resultUrl
@wooya315
Copy link

the code won't work for me too

@renegarcia
Copy link

It works for me, link was shared as publicly available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment