Since Microsoft doesn’t give an obvious way to download sharepoint files through their links, this needed a bit of research. The trick is to share the file (where anyone with the link can download it) and change the link manually.

At the end of the link there’s a question mark. Replace the text after the question mark to download=1

For example,
https://my.sharepoint.com/:u:/g/XXX/XXXX-bunchofRandomText?e=kRlVi

gets replaced to

https://my.sharepoint.com/:u:/g/XXX/XXXX-bunchofRandomText?download=1

Now you can use wget or curl on the link. The problem is that the filename may be wrong, so you have to specify it yourself with -O. for example,

wget https://my.sharepoint.com/:u:/g/XXX/XXXX-bunchofRandomText?download=1 -O /path/to/new/file.avi