問題描述
一個驅動器 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.