Live demo at Spencer's OneDrive Index.
README.mdif found in current folder. Rendered with github-markdown-css.
?proxied- Downloads the file through CloudFlare Workers if (1)
proxyDownloadis true in
config/default.jsand (2) parameter is present in url.
?raw- Return direct raw file instead of rich rendered preview if parameter is present.
?raw&proxiedare both valid.
Yes, this means you can use this project as an image storage service or for serving static files, for example:
See the new features section at the original onedrive-index-cloudflare-worker project page for reference, although I cannot guarantee that all features are usable.
Very, very long, tedious, step by step guide warning! Online token generation tool taken from the generous: https://heymind.github.io/tools/microsoft-graph-api-auth. We will be using this in the following steps.
Namefor your blade app,
Supported account typesto
Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox). OneDrive 世纪互联用户设置为：
任何组织目录（任何 Azure AD 目录 - 多租户）中的帐户.
Redirect URI (optional)to
Web(the multiselect dropdown) and
Get your Application (client) ID -
Certificates & secrets panel, click
New client secret and create a new secret called
Add, and copy the
Value of the
client_secret (You only have this one chance to copy it.).
API permissions panel, select
Microsoft Graph, select
Delegated permissions, search for
offline_access, Files.Read, Files.Read.All, select all three of them and click
You should have these permissions ready:
4. Authorize for code, input our
client_id, and hit
Log into your Microsoft account and authorize our app, if you are returned with a code like what is shown below, then your authorization process is successful:
OK, and proceed on to the next stage.
5. Exchange Access Token, the
Code should already be inputted into the correct place for us, we only need to input our
GET TOKEN. If there is an error like
error: "invalid_request", then please resolve to the solution suggested in the pinned issue #13. Otherwise, collect your
access_token and if you need, use the final
Refresh Token to collect your
refresh_token as well.
Finally, create a dedicated folder for your public files inside OneDrive, for instance:
/Public. Please don't share your root folder directly!
After all this hassle, you should have successfully acquired the following tokens and secrets:
redirect_uri: Defaults to
base: Defaults to
Yes, I know it's a long and tedious procedure, but it's Microsoft, we can understand. 🤷🏼♂️
Fork or directly clone this repository. Install dependencies, you'll need Node.js,
We strongly recommend you install npm with a Node version manager like n or nvm, which will allow wrangler to install configuration data in a global node_modules directory in your user's home directory, without requiring that you run as root.
# Install cloudflare workers official packing and publishing tool npm i @cloudflare/wrangler -g # Install dependencies with npm npm install # Login to Cloudflare with wrangler wrangler login # Verify wrangler status with this command wrangler whoami
Login to your CloudFlare account at https://dash.cloudflare.com/login, select your domain, and scroll down a bit. You'll see your
zone_id there (on the right sidebar). Also create a DRAFT worker at
Manage Workers ->
Create a Worker with a cool name.
name: The draft worker's name, your worker will be published at
account_id: Your Cloudflare Account ID.
zone_id: Your Cloudflare Zone ID.
Create Cloudflare Workers KV bucket named
# Create KV bucket wrangler kv:namespace create "BUCKET" # ... or, create KV bucket with preview functions enabled wrangler kv:namespace create "BUCKET" --preview
kv_namespaces: Your Cloudflare KV namespace, you should substitute the
preview_idvalues accordingly. If you don't need preview functions, you can remove the
basepath from above.
For Chinese 21Vianet OneDrive users. OneDrive 世纪互联用户：将
Add secrets to Cloudflare Workers environment variables with
# Add your refresh_token and client_secret to Cloudflare wrangler secret put REFRESH_TOKEN # ... enter your refresh_token from above here wrangler secret put CLIENT_SECRET # ... enter your client_secret from above here
You can preview the worker with
After making sure everything is ok, you can publish your worker with:
You can also create a GitHub Actions for auto publishing your worker on
push. See main.yml.
For custom domains, refer to How to Setup Cloudflare Workers on a Custom Domain.
introon the default landing page here: src/folderView.js. Write HTML directly.
🏵 onedrive-cf-index ©Spencer Woo. Released under the MIT License.
Authored and maintained by Spencer Woo.