一個驅動器 api 安全 URL (One drive api secure url)


問題描述

一個驅動器 api 安全 URL (One drive api secure url)

簡短:

我在文檔中找不到任何設置 one drive api 獲取沒有訪問令牌無法訪問的文件url

詳情:

我用 queryParameters: "select=id,name,size,file" 嘗試了不同的方法,但無法更改結果

使用 javascript API,當從一個文件中選擇文件時,它會給出一個名為 values 的數組,其中每個對像都包含諸如(一些假但示例值)之類的屬性

@microsoft.graph.downloadUrl: "https://public.sn.files.1drv.com/m7ZHglUdfkMkwg‑qqnNj8"
@odata.context: "https://graph.microsoft.com/v1.0/$metadata#drives('D2CFA54CB9FFC341')/items/$entity"
id: "FA4454CB9FFC341!172"
name: "sada.pdf"
size: 4344

我獲得上述結果的代碼是

var odOptions = {
    clientId: "df45ae45‑68bd‑4568‑a473‑4159a1b16fc1",
    action: "download",
    multiSelect: true,
    // openInNewWindow: true,
    // advanced: {
    //     queryParameters: "/drive/root/children?select=id,name,size,file",
    // },
    success: function (response) {
        console.log(555, response); 
    },
    cancel: function (response) { console.log(response); },
    error: function (e) { console.log(e); }
};
OneDrive.open(odOptions);

問題是 https://public.sn.files.. 公共 url(任何人都可以訪問文件而無需使用此 url 登錄)不像谷歌驅動器提供安全 url


參考解法

方法 1:

The downloadUrl is a short lived URL that is preauthenticated so that authorization is not required. Access control checks are instead performed on the request that returns the URL. A flow that's closer to what Google Drive utilizes would be to hit the /content endpoint for a specific file ‑ this request requires an OAuth token to be provided and will return the binary content.

(by SamiBrad)

參考文件

  1. One drive api secure url (CC BY‑SA 2.5/3.0/4.0)

#onedrive #javascript






相關問題

WP7-Skydrive API 下載任何文件並保存隔離存儲 (WP7-Skydrive API Download Any file and Save Isolated Storage)

如何編寫 .NET 控制台應用程序來訪問 SkyDrive? (How can I write a .NET console application to access SkyDrive?)

Loại đăng nhập Skydrive API Windows 8 (Skydrive API login type Windows 8)

如何使用 Rest api 和 oauth2.0 創建文件夾和上傳文件 (How to create folder and upload file using Rest api and oauth2.0)

從 ERP 保存到 OneDrive (Save to OneDrive from ERP)

適用於 Windows 通用 APP 的 OneDrive Api (OneDrive Api for Windows Universal APP)

一種 Drive / Office365 與 Google Apps Script 類似的腳本語言 (One Drive / Office365 similar scripting language as the Google Apps Script)

OneDrive API 瀏覽器 C# (OneDrive API browser C#)

從 Python 應用程序訪問 Microsoft Live 服務 (Access Microsoft Live services from Python application)

一個驅動器 api 安全 URL (One drive api secure url)

嘗試使用 get-PnPFile 從 OneDrive 獲取文件的所有版本時找不到文件 (File not found trying to get all versions of a file from OneDrive using get-PnPFile)

一個驅動器遷移 (One Drive Migration)







留言討論