简体   繁体   中英

OneDrive REST API - CORS POST request

I'm trying to create a folder using the OneDrive REST API following the official documentation ( http://msdn.microsoft.com/en-us/library/dn659743.aspx#create_a_folder ). I have implemented it as AJAX request in JavaScript, which results in a CORS request in the browser.

As expected, the browser sends a first OPTIONS request with the relevant headers:

Access-Control-Request-Headers:authorization, content-type
Access-Control-Request-Method:POST

The response headers, however, does not include authorization as allowed header:

Access-Control-Allow-Headers:Content-Type
Access-Control-Allow-Methods:GET, POST, DELETE, PUT, HEAD, MOVE, COPY
Access-Control-Allow-Origin:*
Access-Control-Max-Age:2592000

Consequently, the browser (Chromium 34 in this case) logs an error in the console and does not submit the POST request, since it is not allowed to add the Authorization header:

XMLHttpRequest cannot load https://apis.live.net/v5.0/me/skydrive. Request header field authorization is not allowed by Access-Control-Allow-Headers.

Is there any way to get around this issue? From my understanding this is a server issue, since the documentation explicitly asks for this header.

您仍然应该能够将access_token作为查询参数提供,例如“删除文件夹”示例(并且不要通过Authorization标头提供)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM