Advanced
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:
- Microsoft Azure App registrations (for OneDrive international, OneDrive for Business or Education), or...
- Microsoft Azure.cn App registrations (OneDrive 世纪互联版本)
Create a new blade app:
-
Login with your Microsoft account, select New registration.
-
Enter the Name for your blade app,
my-onedrive-vercel-index
for example. -
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 目录 - 多租户)中的帐户.
-
Set Redirect URI (optional) to
Web
(the multiselect dropdown) andhttp://localhost
(the URL). -
Click Register.
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 client secret needs to be generated manually:
- Open Certificates & secrets panel.
- Click New client secret.
- Create a new secret with description
client_secret
. - Set Expires to
Custom
. - Change Start and End to the longest available time duration available.
Finally, click Add, and copy the Value of the client_secret (You only have this one chance to copy it).
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.
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.
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.
Discussed at: 关于使用自己的 secret 进行 AES 加密方式的小白解决办法.
Setting up a custom domain
Check out Custom Domains - Vercel.