little_onedrive_spwa is a Single Page Web Application (SPWA) to connect to the OneDrive REST API.
Check out the SPWA : https://aliceliveprojects.github.io/little_onedrive_spwa/src/index.html
The SPWA can do two things:
Before you can use the wonderful SPWA you need to setup a Microsoft developer account.
Within a specific application :
Within the script.js file locate appInfo on Line 7. Modify appInfo to the appropriate details, these details must match with the application details filled out earlier.
clientId : application Id
redirectUri : application redirect URL
scopes: application scopes delimited by a space and formatted to lowercase (example Sites.Read.All ===> sites.read.all)
authServiceUri: don’t change (should be https://login.microsoftonline.com/common/oauth2/v2.0/authorize)
Deploying the application is really easy.
npm installnode server.jsTo run the SPWA on https read https://digitallabs.mmu.ac.uk/taming-the-urban-wild/#more-1657
Some notes on the OneDrive API, which I painfully found so you don’t have to.
The OneDrive REST API provides two ways to download the contents of a file :
Using the /content endpoint
Using the ‘@microsoft.graph.downloadUrl’ property
The /content endpoint returns a 302 response redirecting to a temporary pre-authenticated url to download the file contents. Requesting the /content endpoint from a sever works great, but, requesting from client-side the 302 causes a CORS error.
For more information look at Issues or Issues Archived
To download the file the contents from client side the ‘@microsoft.graph.downloadUrl’ property can be used. First you must request files meta-data which includes the ‘@microsoft.graph.downloadUrl’ property. The ‘@microsoft.graph.downloadUrl’ provides a temporary authenticated url to download file contents.
When requesting the ‘@microsoft.graph.downloadUrl’ url DO NOT send any Authorisation headers. Sending Authorisation headers will cause a :
CORS error when requesting from client
404 error when reqeusting from server
For more information at Docs or Docs Archived