Advanced

♻️
Continuously updating here.

Some of the more advanced configurations here. You may or may not be looking for them.

Using your own clientId and clientSecret

If you are not the admin of your OneDrive account, you may not be able to use the project's clientId and clientSecret provided by me. In this case, you would need to generate your own client id and secret for authentication.

Register a new application

Open the following link:

Create a new blade app:

  1. Login with your Microsoft account, select New registration.

  2. Enter the Name for your blade app, my-onedrive-vercel-index for example.

  3. Set Supported account types to:

    Accounts in any organizational directory (Any Azure AD directory - Multitenant) and personal Microsoft accounts (e.g. Skype, Xbox)
    

    OneDrive 世纪互联用户设置为 - 任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户.

  4. Set Redirect URI (optional) to Web (the multiselect dropdown) and http://localhost (the URL).

  5. Click Register.

Register a new application

Get your client id and secret

Your Application (client) ID is the clientId to appear in your api.config.js. It should be present at Overview > Essentials.

Your application (client) ID

Your client secret needs to be generated manually:

  1. Open Certificates & secrets panel.
  2. Click New client secret.
  3. Create a new secret with description client_secret.
  4. Set Expires to Custom.
  5. Change Start and End to the longest available time duration available.

Generate a client secret

Finally, click Add, and copy the Value of the client_secret (You only have this one chance to copy it).

Copy your client secret

Modify API permissions

Microsoft Graph API comes with API permission scopes. Our project only requires the following (which are defined in api.config.js):

user.read files.read.all offline_access

Open API permissions, select Microsoft Graph, select Delegated permissions, and search for:

  • User.Read (this should already be available)
  • Files.Read.All
  • offline_access

Select all three of them and click Add permissions.

Modify Microsoft Graph API permissions

💡
At this point, you should have your clientId and clientSecret ready.

Modify configs in api.config.js

You can directly replace clientId with your generated clientId.

However, client secret is more involved. You need to obfuscate it with AES encryption.

Obfuscate your client secret 👇
Your client secret:
Your obfuscated client secret:

You should get an obfuscated client secret which looks like:

U2FsdGVkX1830zo3/pFDqaBCVBb37iLw3WnBDWGF9GIB2f4apzv0roemp8Y+iIxI3Ih5ecyukqELQEGzZlYiWg==

Replace the obfuscatedClientSecret with this value.

If you changed redirectUri to something other than http://localhost, you need to change that in api.config.js as well.

Setting up a custom domain

Check out Custom Domains - Vercel.