Skip to content

Thêm OneDrive Channel

Cần chuẩn bị trước

RequirementVì sao cần
Microsoft accountDùng để access Microsoft admin pages và authorize OneDrive
ImgBed domain của bạnDùng cho OAuth callback URL
App registrationDùng để generate Client IDClient Secret
OneDrive accountDùng làm nơi lưu file thực tế

Các bước thiết lập

Step 1: Mở Microsoft Entra ID

  1. Mở portal.azure.com.
  2. Tìm Microsoft Entra ID ở phía trên.
  3. Nếu trang cần tìm không hiện trong dropdown, chọn:
text
Continue searching in Microsoft Entra ID
  1. Mở Microsoft Entra ID.
  2. Mở App registrations.
  3. Nhấn New registration.

Step 2: Register App

Trên trang New registration, điền:

FieldNhập gì
NameTên dễ nhận biết, ví dụ imgbed-onedrive
Supported account typesChọn theo bảng bên dưới
Redirect URI typeWeb
Redirect URIhttps://your-domain.com/api/oauth/onedrive/callback

Gợi ý chọn account type:

Tình huống của bạnSupported Account Types
Chỉ dùng personal OneDriveChọn option cho personal Microsoft account.
Dùng cả personal và work/school accountsChọn option hỗ trợ cả personal và organizational accounts.
Chỉ dùng company hoặc school OneDriveChọn organizational account option.

Điền xong thì nhấn register.

Create OneDrive app

Step 3: Copy App Information

Sau khi app được tạo, copy các giá trị này từ overview page:

Microsoft FieldImgBed Field
Application (client) IDClient ID
Directory (tenant) IDTenant ID cho organizational accounts

Application and tenant IDs

Step 4: Tạo Client Secret

  1. Mở Certificates & secrets.
  2. Nhấn New client secret.
  3. Nhập description tùy ý.
  4. Chọn expiration period.
  5. Copy Value ngay sau khi tạo.

Save client secret value

Step 5: Thêm API Permissions

  1. Mở API permissions.
  2. Nhấn Add a permission.
  3. Chọn Microsoft Graph.
  4. Chọn Delegated permissions.
  5. Thêm các permissions này:
PermissionPurpose
Files.ReadWrite.AllUpload files, tạo folders và xóa files
offline_accessCho phép ImgBed lấy Refresh Token
User.ReadĐọc account và quota information

Step 6: Điền OneDrive Channel

Trong Upload Settings, chọn OneDrive và điền:

ImgBed FieldNhập gì
Channel nameTên dễ nhận biết, ví dụ Main OneDrive
Client IDMicrosoft Application (client) ID
Client SecretClient Secret Value đã copy
Tenant IDDùng bảng bên dưới
Refresh TokenTạm thời để trống
Root directoryOptional. Mặc định là imgbed.
NoteOptional

Fill OneDrive channel config

Cách điền Tenant ID:

Account Type You ChoseImgBed Tenant ID
Personal accountsconsumers
Personal + organizational accountscommon
Current organization onlyDirectory (tenant) ID

Step 7: Lấy Refresh Token

  1. Trong ImgBed, nhấn Get Token.
  2. Sign in vào Microsoft account bạn muốn kết nối.
  3. Approve authorization prompt.
  4. Callback page sẽ hiển thị Refresh Token.
  5. Copy token đó.
  6. Quay lại ImgBed và paste vào field Refresh Token.

Copy refresh token

Step 8: Save Channel

Sau khi điền đủ fields, save channel.

Quick Flow

text
Mở portal.azure.com
-> Tìm Microsoft Entra ID
-> Mở App registrations
-> Register app mới
-> Điền Name / Supported account types / Web redirect URI
-> Register
-> Copy Application (client) ID
-> Kiểm tra callback URL trong Authentication
-> Tạo Client Secret trong Certificates & secrets
-> Thêm permissions trong API permissions
-> Điền Client ID / Client Secret / Tenant ID vào ImgBed
-> Nhấn Get Token
-> Copy Refresh Token từ callback page
-> Paste lại vào ImgBed và save

References

  1. Microsoft Entra app registration: https://learn.microsoft.com/en-us/entra/identity-platform/quickstart-register-app
  2. Microsoft identity platform authorization code flow: https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-auth-code-flow
  3. Microsoft Graph user authentication: https://learn.microsoft.com/en-us/graph/auth-v2-user

Released as user documentation for CloudFlare ImgBed.