OneDrive Api 获取方法(没有人可以修复它:S)
OneDrive Api GET METHOD (No One Can Fix It :S)
$.ajax({
url: 'https://login.live.com/oauth20_authorize.srf?client_id=*********&scope=onedrive.readwrite&response_type=token&redirect_uri=http://localhost:54540/Home/Dashboard',
dataType: "json",
type: "GET",
contentType: 'application/json; charset=utf-8',
async: true,
processData: false,
cache: false,
success: function(data) {
alert(data);
},
error: function(xhr) {
alert('error');
}
});
我收到以下错误
请求的资源上不存在 'Access-Control-Allow-Origin' header。因此不允许访问来源“http://localhost:54540”。
我知道它是关于 CORS 的,但我找不到任何简单的解决方案。
您似乎在尝试使用 ajax 从登录服务器获取授权令牌。由于此过程可能涉及要求您的应用用户登录或同意让您的应用访问他们的数据,因此您需要在浏览器本身中导航到该 URL。
这里是more info about using oauth with OneDrive. You should also take a look at the javascript sample app,看看它在实践中是如何工作的。
$.ajax({
url: 'https://login.live.com/oauth20_authorize.srf?client_id=*********&scope=onedrive.readwrite&response_type=token&redirect_uri=http://localhost:54540/Home/Dashboard',
dataType: "json",
type: "GET",
contentType: 'application/json; charset=utf-8',
async: true,
processData: false,
cache: false,
success: function(data) {
alert(data);
},
error: function(xhr) {
alert('error');
}
});
我收到以下错误 请求的资源上不存在 'Access-Control-Allow-Origin' header。因此不允许访问来源“http://localhost:54540”。
我知道它是关于 CORS 的,但我找不到任何简单的解决方案。
您似乎在尝试使用 ajax 从登录服务器获取授权令牌。由于此过程可能涉及要求您的应用用户登录或同意让您的应用访问他们的数据,因此您需要在浏览器本身中导航到该 URL。
这里是more info about using oauth with OneDrive. You should also take a look at the javascript sample app,看看它在实践中是如何工作的。