Skip to content

Thêm Yandex Channel

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

Yêu cầuVì sao cần
Yandex accountDùng để sign in và authorize Yandex Disk
Yandex OAuth appDùng để generate Client IDClient Secret
ImgHost domain của bạnDùng cho OAuth redirect URI
Available Yandex Disk storageDùng làm nơi lưu file thực tế

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

Bước 1: Tạo Yandex OAuth App

  1. Mở trang tạo Yandex OAuth app:
text
https://oauth.yandex.com/client/new
  1. Nếu bị redirect sang sign in, hãy sign in bằng Yandex account trước.
  2. Tạo app mới.
  3. Đặt tên app dễ nhận biết, ví dụ imgbed-yandex.
  4. Tìm phần callback hoặc redirect URL settings.
  5. Nhập:
text
https://your-domain.com/api/oauth/yandex/callback

Bước 2: Xác nhận Quyềns

Với ImgHost Yandex integration hiện tại, giữ bốn permissions này trong Yandex.Disk REST API:

QuyềnMục đích
cloud_api:disk.app_folderCho phép ImgHost lưu files trong app folder
cloud_api:disk.readĐọc files và download links
cloud_api:disk.writeUpload files, tạo folders và xóa files
Access to information about Yandex.DiskĐọc disk quota và used space

Nếu cũng thấy các permissions này trong Yandex ID API, chúng là không bắt buộc:

Văn bản quyềnKhuyến nghị
Access to username, first name and surname, genderKhông bắt buộc
Access to email addressKhông bắt buộc

Các tính năng upload, download, deletion và quota chủ yếu phụ thuộc vào bốn permissions Yandex.Disk REST API ở trên.

Configure Yandex Disk permissions

Bước 3: Sao chép App Credentials

Sau khi app được tạo, sao chép:

Trường YandexTrường ImgHost
Client IDClient ID
Client SecretClient Secret

Ghi lại Client ID và Secret

Bước 4: Điền Yandex Channel

Trong Cài đặt tải lên, chọn Yandex và điền:

Trường ImgHostNhập gì
Channel nameTên dễ nhận biết, ví dụ Main Yandex
Client IDYandex app Client ID
Client SecretYandex app Client Secret
Refresh TokenTạm thời để trống
Root directoryKhông bắt buộc. Mặc định là imgbed.

Sửa config kênh

Bước 5: Lấy Refresh Token

  1. Trong ImgHost, nhấn Get Token.
  2. Sign in vào Yandex account bạn muốn kết nối.
  3. Phê duyệt authorization prompt.
  4. Callback page sẽ hiển thị Refresh Token.
  5. Sao chép token đó.
  6. Quay lại ImgHost và dán vào trường Refresh Token.

Sao chép refresh token sau authorization

Bước 6: Save Channel

Sau khi điền đủ trường, save channel.

Luồng nhanh

text
Open Yandex OAuth Console
-> Create an app
-> Add https://your-domain.com/api/oauth/yandex/callback
-> Confirm Yandex Disk permissions
-> Copy Client ID and Client Secret
-> Fill Client ID / Client Secret into ImgHost
-> Click Get Token
-> Copy the Refresh Token from the callback page
-> Paste it back into ImgHost and save

Tài liệu tham khảo

  1. Register a Yandex app: https://yandex.com/dev/id/doc/en/register-client
  2. Lấy authorization code qua URL: https://yandex.com/dev/id/doc/en/codes/code-url
  3. Yandex OAuth token endpoint: https://yandex.com/dev/id/doc/en/tokens/token

Released as user documentation for ImgHost.